source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: docbook2mdoc: Do not include literal linefeed characters in text nodes;
Date: Thu, 11 Apr 2019 23:17:42 -0500 (EST)	[thread overview]
Message-ID: <e3fdae760ba3b240@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Do not include literal linefeed characters in text nodes;
instead, let the parser split them into two text nodes.

For now, let the formatter start text nodes preceded by whitespace 
on new output lines, which is a crude way of preserving input line
breaks and making sure output text lines are limited to reasonable
length.

Modified Files:
--------------
    docbook2mdoc:
        docbook2mdoc.c
        parse.c

Revision Data
-------------
Index: parse.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/parse.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -Lparse.c -Lparse.c -u -p -r1.32 -r1.33
--- parse.c
+++ parse.c
@@ -972,9 +972,11 @@ parse_string(struct parse *p, char *b, s
 
 		} else {
 			advance(p, b, rlen, &pend,
-			    p->ncur == NODE_DOCTYPE ? "<&]" : "<&",
+			    p->ncur == NODE_DOCTYPE ? "<&]\n" : "<&\n",
 			    refill);
 			xml_char(p, b + poff, pend - poff);
+			if (b[pend] == '\n')
+				pnode_closetext(p);
 		}
 	}
 	return poff;
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.104 -r1.105
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -81,8 +81,14 @@ pnode_printtext(struct format *f, struct
 
 	switch (f->linestate) {
 	case LINE_TEXT:
-		if (n->spc)
+		if (n->spc) {
+			if (n->node == NODE_TEXT) {
+				putchar('\n');
+				last = '\n';
+				break;
+			}
 			putchar(' ');
+		}
 		last = ' ';
 		break;
 	case LINE_MACRO:
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

                 reply	other threads:[~2019-04-12  4:17 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=e3fdae760ba3b240@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).