* texi2mdoc: Add @verb{} support.
@ 2015-02-23 12:40 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2015-02-23 12:40 UTC (permalink / raw)
To: source
Log Message:
-----------
Add @verb{} support.
Modified Files:
--------------
texi2mdoc:
extern.h
main.c
texi2mdoc.1
Revision Data
-------------
Index: extern.h
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/extern.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lextern.h -Lextern.h -u -p -r1.7 -r1.8
--- extern.h
+++ extern.h
@@ -207,6 +207,7 @@ enum texicmd {
TEXICMD_URL,
TEXICMD_VALUE,
TEXICMD_VAR,
+ TEXICMD_VERB,
TEXICMD_VERBATIM,
TEXICMD_VERBATIMINCLUDE,
TEXICMD_VINDEX,
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -Lmain.c -Lmain.c -u -p -r1.32 -r1.33
--- main.c
+++ main.c
@@ -74,6 +74,7 @@ static void dotab(struct texi *, enum te
static void dotitle(struct texi *, enum texicmd, const char *, size_t, size_t *);
static void dovalue(struct texi *, enum texicmd, const char *, size_t, size_t *);
static void doverb(struct texi *, enum texicmd, const char *, size_t, size_t *);
+static void doverbatim(struct texi *, enum texicmd, const char *, size_t, size_t *);
static void doverbinclude(struct texi *, enum texicmd, const char *, size_t, size_t *);
static const struct texitok __texitoks[TEXICMD__MAX] = {
@@ -262,7 +263,8 @@ static const struct texitok __texitoks[T
{ dolink, "url", 3 }, /* TEXICMD_URL */
{ dovalue, "value", 5 }, /* TEXICMD_VALUE */
{ doinline, "var", 3 }, /* TEXICMD_VAR */
- { doverb, "verbatim", 8 }, /* TEXICMD_VERBATIM */
+ { doverb, "verb", 4 }, /* TEXICMD_VERB */
+ { doverbatim, "verbatim", 8 }, /* TEXICMD_VERBATIM */
{ doverbinclude, "verbatiminclude", 15 }, /* TEXICMD_VERBATIMINCLUDE */
{ doignline, "vindex", 6 }, /* TEXICMD_VINDEX */
{ dosp, "vskip", 5 }, /* TEXICMD_VSKIP */
@@ -586,6 +588,42 @@ doinline(struct texi *p, enum texicmd cm
static void
doverb(struct texi *p, enum texicmd cmd,
+ const char *buf, size_t sz, size_t *pos)
+{
+ char delim;
+
+ while (*pos < sz && isws(buf[*pos]))
+ advance(p, buf, pos);
+ if (*pos == sz || '{' != buf[*pos])
+ return;
+ advance(p, buf, pos);
+ if (*pos == sz)
+ return;
+
+ delim = buf[*pos];
+ advance(p, buf, pos);
+ /* Make sure we flush out our initial whitespace... */
+ if (p->seenws && p->outcol && 0 == p->literal)
+ texiputchar(p, ' ');
+ p->seenws = 0;
+ /* Read until we see the delimiter then end-brace. */
+ while (*pos < sz - 1) {
+ if (buf[*pos] == delim && buf[*pos + 1] == '}')
+ break;
+ texiputchar(p, buf[*pos]);
+ advance(p, buf, pos);
+ }
+ if (*pos == sz - 1)
+ return;
+ /* Make sure we read after the end-brace. */
+ assert(delim == buf[*pos]);
+ advance(p, buf, pos);
+ assert('}' == buf[*pos]);
+ advance(p, buf, pos);
+}
+
+static void
+doverbatim(struct texi *p, enum texicmd cmd,
const char *buf, size_t sz, size_t *pos)
{
const char *end, *term;
Index: texi2mdoc.1
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/texi2mdoc.1,v
retrieving revision 1.6
retrieving revision 1.7
diff -Ltexi2mdoc.1 -Ltexi2mdoc.1 -u -p -r1.6 -r1.7
--- texi2mdoc.1
+++ texi2mdoc.1
@@ -84,13 +84,17 @@ The
utility was written by
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
.Sh CAVEATS
-Amongst others, the
-.Li @macro
-and macro-related commands,
-.Li @verb ,
-and
-.Li @footnote
-are not supported.
+The output of
+.Nm
+doesn't play entirely nicely with
+.Xr mdoc 7 .
+It doesn't detect whether a line trailing slash is properly escaped, nor
+does it properly account for how it mingles
+.Sq \&Pp
+with the text.
+Moreover, many commands that might contain useful information (such as
+.Li @footnote )
+are thrown away.
.\" .Sh BUGS
.Sh SECURITY CONSIDERATIONS
As a security precaution,
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-02-23 12:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-23 12:40 texi2mdoc: Add @verb{} support kristaps
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).