source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* docbook2mdoc: Do not include literal linefeed characters in text nodes;
@ 2019-04-12  4:17 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-12  4:17 UTC (permalink / raw)
  To: source

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

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

only message in thread, other threads:[~2019-04-12  4:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12  4:17 docbook2mdoc: Do not include literal linefeed characters in text nodes; 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).