source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* docbook2mdoc: In no-fill context, do not break the output line when a
@ 2019-05-01 15:06 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-05-01 15:06 UTC (permalink / raw)
  To: source

Log Message:
-----------
In no-fill context, do not break the output line when a text node
on a text line is followed by a macro node.

Modified Files:
--------------
    docbook2mdoc:
        docbook2mdoc.c
        macro.c
        macro.h

Revision Data
-------------
Index: macro.h
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/macro.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lmacro.h -Lmacro.h -u -p -r1.5 -r1.6
--- macro.h
+++ macro.h
@@ -34,6 +34,7 @@ enum	parastate {
 
 struct	format {
 	int		 level;      /* Header level, starting at 1. */
+	int		 nofill;     /* Level of no-fill block nesting. */
 	int		 flags;
 #define	FMT_NOSPC	 (1 << 0)    /* Suppress space before next node. */
 #define	FMT_ARG		 (1 << 1)    /* May add argument to current macro. */
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.145 -r1.146
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -930,6 +930,9 @@ pnode_print(struct format *f, struct pno
 	if (n == NULL)
 		return;
 
+	if (f->nofill && n->flags & NFLAG_LINE)
+		macro_close(f);
+
 	was_impl = f->flags & FMT_IMPL;
 	if (n->flags & NFLAG_SPC)
 		f->flags &= ~FMT_NOSPC;
@@ -1193,6 +1196,9 @@ pnode_print(struct format *f, struct pno
 		break;
 	}
 
+	if (pnode_class(n->node) == CLASS_NOFILL)
+		f->nofill++;
+
 	TAILQ_FOREACH(nc, &n->childq, child)
 		pnode_print(f, nc);
 
@@ -1306,6 +1312,8 @@ pnode_print(struct format *f, struct pno
 		break;
 	}
 	f->flags &= ~FMT_ARG;
+	if (pnode_class(n->node) == CLASS_NOFILL)
+		f->nofill--;
 }
 
 void
@@ -1313,7 +1321,7 @@ ptree_print_mdoc(struct ptree *tree)
 {
 	struct format	 formatter;
 
-	formatter.level = 0;
+	formatter.level = formatter.nofill = 0;
 	formatter.linestate = LINE_NEW;
 	formatter.parastate = PARA_HAVE;
 	pnode_printprologue(&formatter, tree->root);
Index: macro.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/macro.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -Lmacro.c -Lmacro.c -u -p -r1.16 -r1.17
--- macro.c
+++ macro.c
@@ -49,6 +49,8 @@ macro_open(struct format *f, const char 
 		}
 		/* FALLTHROUGH */
 	case LINE_TEXT:
+		if (f->nofill)
+			fputs(" \\c", stdout);
 		putchar('\n');
 		/* FALLTHROUGH */
 	case LINE_NEW:
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

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

only message in thread, other threads:[~2019-05-01 15:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 15:06 docbook2mdoc: In no-fill context, do not break the output line when a 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).