From: Ingo Schwarze <schwarze@usta.de>
To: "Anthony J. Bentley" <anthony@anjbe.name>
Cc: tech@mandoc.bsd.lv
Subject: Re: docbook2mdoc(1) sometimes mishandles
Date: Mon, 20 May 2019 22:38:52 +0200 [thread overview]
Message-ID: <20190520203852.GA10196@athene.usta.de> (raw)
In-Reply-To: <3491.1558341259@desktop.ajb.soy>
Hi Anthony,
Anthony J. Bentley wrote on Mon, May 20, 2019 at 02:34:19AM -0600:
> From fonts.xml:
>
> <sect3 id='Standard_Type1_fonts'>
> <title>Standard Type 1 fonts</title>
>
> docbook2mdoc turns this into:
>
> .Pp
> .Sy Standard Type\e1 fonts
>
> It happens again near the end of the document:
>
> <para>
> The IETF RFC documents, available from a number of sites throughout
> the world, often provide interesting information about character set
> issues; see for example <ulink
> url="https://datatracker.ietf.org/doc/rfc373/">RFC 373</ulink>.
> </para>
>
> becomes:
>
> .Pp
> The IETF RFC documents, available from a number of sites throughout
> the world, often provide interesting information about character set
> issues; see for example
> .Lk https://datatracker.ietf.org/doc/rfc373/ "RFC\e373" .
Thanks for reporting, fxied with the following commit.
Strangely, the file fonts.7 in the Xenocara tree is already correct...
Yours,
Ingo
Log Message:
-----------
When rendering XML entities, skip escaping in macro_addarg().
Fixing a bug which bentley@ found in fonts(7).
Modified Files:
--------------
docbook2mdoc:
macro.c
macro.h
Revision Data
-------------
Index: macro.h
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/macro.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lmacro.h -Lmacro.h -u -p -r1.7 -r1.8
--- macro.h
+++ macro.h
@@ -44,10 +44,11 @@ struct format {
enum parastate parastate;
};
-#define ARG_SPACE 1 /* Insert whitespace before this argument. */
-#define ARG_SINGLE 2 /* Quote argument if it contains whitespace. */
-#define ARG_QUOTED 4 /* We are already in a quoted argument. */
-#define ARG_UPPER 8 /* Covert argument to upper case. */
+#define ARG_SPACE (1 << 0) /* Insert whitespace before this argument. */
+#define ARG_SINGLE (1 << 1) /* Quote arg if it contains whitespace. */
+#define ARG_QUOTED (1 << 2) /* We are already in a quoted argument. */
+#define ARG_RAW (1 << 3) /* Skip macro and backslash escaping. */
+#define ARG_UPPER (1 << 4) /* Convert argument to upper case. */
void macro_open(struct format *, const char *);
Index: macro.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/macro.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lmacro.c -Lmacro.c -u -p -r1.20 -r1.21
--- macro.c
+++ macro.c
@@ -130,6 +130,13 @@ macro_addarg(struct format *f, const cha
flags &= ~ ARG_SPACE;
}
+ /* For XML entities, skip escaping. */
+
+ if (flags & ARG_RAW) {
+ fputs(arg, stdout);
+ break;
+ }
+
/* Escape us if we look like a macro. */
if ((flags & (ARG_QUOTED | ARG_UPPER)) == 0 &&
@@ -186,10 +193,16 @@ macro_addnode(struct format *f, struct p
TAILQ_NEXT(nc, child) == NULL)
n = nc;
- if (n->node == NODE_TEXT || n->node == NODE_ESCAPE) {
+ switch (n->node) {
+ case NODE_ESCAPE:
+ flags |= ARG_RAW;
+ /* FALLTHROUGH */
+ case NODE_TEXT:
macro_addarg(f, n->b, flags);
f->parastate = PARA_MID;
return;
+ default:
+ break;
}
/*
--
To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv
prev parent reply other threads:[~2019-05-20 20:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-20 8:34 Anthony J. Bentley
2019-05-20 20:38 ` Ingo Schwarze [this message]
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=20190520203852.GA10196@athene.usta.de \
--to=schwarze@usta.de \
--cc=anthony@anjbe.name \
--cc=tech@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).