source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: docbook2mdoc: In no-fill context, do not break the output line when a
Date: Wed, 1 May 2019 10:06:10 -0500 (EST)	[thread overview]
Message-ID: <e3fedb1ae2307137@fantadrom.bsd.lv> (raw)

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

                 reply	other threads:[~2019-05-01 15:06 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=e3fedb1ae2307137@fantadrom.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.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).