* docbook2mdoc: handle preceding a macro without intervening whitespace
@ 2019-04-07 14:49 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-07 14:49 UTC (permalink / raw)
To: source
Log Message:
-----------
handle preceding a macro without intervening whitespace
Modified Files:
--------------
docbook2mdoc:
docbook2mdoc.c
parse.c
Revision Data
-------------
Index: parse.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/parse.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -Lparse.c -Lparse.c -u -p -r1.16 -r1.17
--- parse.c
+++ parse.c
@@ -456,8 +456,50 @@ xml_elem_start(struct parse *ps, const c
perror(NULL);
exit(1);
}
- dat->node = elem->node;
- dat->spc = ps->spc;
+
+ /*
+ * Nodes that begin a new macro or request line or start by
+ * printing text always want whitespace before themselves.
+ */
+
+ switch (dat->node = elem->node) {
+ case NODE_AUTHORGROUP:
+ case NODE_BOOKINFO:
+ case NODE_CAUTION:
+ case NODE_EDITOR:
+ case NODE_ENTRY:
+ case NODE_FUNCDEF:
+ case NODE_FUNCPROTOTYPE:
+ case NODE_INFORMALEQUATION:
+ case NODE_INLINEEQUATION:
+ case NODE_ITEMIZEDLIST:
+ case NODE_LEGALNOTICE:
+ case NODE_LITERALLAYOUT:
+ case NODE_NOTE:
+ case NODE_ORDEREDLIST:
+ case NODE_PARA:
+ case NODE_PREFACE:
+ case NODE_PROGRAMLISTING:
+ case NODE_REFMETA:
+ case NODE_REFNAMEDIV:
+ case NODE_REFSYNOPSISDIV:
+ case NODE_ROW:
+ case NODE_SBR:
+ case NODE_SCREEN:
+ case NODE_SECTION:
+ case NODE_SYNOPSIS:
+ case NODE_TGROUP:
+ case NODE_TIP:
+ case NODE_TITLE:
+ case NODE_VARIABLELIST:
+ case NODE_VARLISTENTRY:
+ case NODE_WARNING:
+ dat->spc = 1;
+ break;
+ default:
+ dat->spc = ps->spc;
+ break;
+ }
dat->parent = ps->cur;
TAILQ_INIT(&dat->childq);
TAILQ_INIT(&dat->attrq);
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.93 -r1.94
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -34,12 +34,26 @@ static void pnode_print(struct format *
static void
pnode_printtext(struct format *f, struct pnode *n)
{
+ struct pnode *nn;
char *cp;
char last;
if (n->bsz == 0) {
assert(n->real < n->b);
return;
+ }
+
+ /*
+ * Text preceding a macro without intervening whitespace
+ * requires a .Pf macro.
+ * Set the spacing flag to avoid a redundant .Ns macro.
+ */
+
+ if (f->linestate != LINE_MACRO &&
+ (nn = TAILQ_NEXT(n, child)) != NULL && nn->spc == 0 &&
+ (nn->node != NODE_TEXT && nn->node != NODE_ESCAPE)) {
+ macro_open(f, "Pf");
+ nn->spc = 1;
}
if (f->linestate == 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-04-07 14:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-07 14:49 docbook2mdoc: handle preceding a macro without intervening whitespace 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).