From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: pod2mdoc: Account for sections as well as links.
Date: Thu, 3 Apr 2014 07:34:30 -0400 (EDT) [thread overview]
Message-ID: <201404031134.s33BYUIQ026125@krisdoz.my.domain> (raw)
Log Message:
-----------
Account for sections as well as links.
Modified Files:
--------------
pod2mdoc:
pod2mdoc.1
pod2mdoc.c
Revision Data
-------------
Index: pod2mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/pod2mdoc/pod2mdoc.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lpod2mdoc.c -Lpod2mdoc.c -u -p -r1.19 -r1.20
--- pod2mdoc.c
+++ pod2mdoc.c
@@ -215,8 +215,8 @@ trylink(const char *buf, size_t *start,
if ('|' == buf[textsz] || '/' == buf[textsz])
break;
- /* If we have a title, find the section. */
if (textsz < linkend && '|' == buf[textsz]) {
+ /* With title: set start, then end at section. */
linkstart = textsz + 1;
textsz = textsz - *start;
for (i = linkstart; i < linkend; i++)
@@ -224,32 +224,43 @@ trylink(const char *buf, size_t *start,
break;
if (i < linkend)
linkend = i;
- } else {
+ } else if (textsz < linkend && '/' == buf[textsz]) {
+ /* With section: set end at section. */
+ linkend = textsz;
+ textsz = 0;
+ } else
+ /* No title, no section. */
textsz = 0;
- if (textsz < linkend && '/' == buf[textsz])
- linkend = textsz;
- }
*start = realend;
-
j = linkend - linkstart;
- if (0 == j)
+ /* Do we have only subsection material? */
+ if (0 == j && '/' == buf[linkend]) {
+ linkstart = linkend + 1;
+ linkend = dsz > 1 ? realend - 1 : realend;
+ if (0 == (j = linkend - linkstart))
+ return(0);
+ printf("Sx %.*s", (int)j, &buf[linkstart]);
+ return(1);
+ } else if (0 == j)
return(0);
/* See if we qualify as being a link or not. */
- if ((j > 5 && 0 == memcmp("http:", &buf[linkstart], j)) ||
- (j > 6 && 0 == memcmp("https:", &buf[linkstart], j)) ||
- (j > 4 && 0 == memcmp("ftp:", &buf[linkstart], j)) ||
- (j > 5 && 0 == memcmp("sftp:", &buf[linkstart], j)) ||
- (j > 4 && 0 == memcmp("smb:", &buf[linkstart], j)) ||
- (j > 4 && 0 == memcmp("afs:", &buf[linkstart], j))) {
- printf("Lk %.*s", (int)j, &buf[linkstart]);
+ if ((j > 4 && 0 == memcmp("http:", &buf[linkstart], j)) ||
+ (j > 5 && 0 == memcmp("https:", &buf[linkstart], j)) ||
+ (j > 3 && 0 == memcmp("ftp:", &buf[linkstart], j)) ||
+ (j > 4 && 0 == memcmp("sftp:", &buf[linkstart], j)) ||
+ (j > 3 && 0 == memcmp("smb:", &buf[linkstart], j)) ||
+ (j > 3 && 0 == memcmp("afs:", &buf[linkstart], j))) {
+ /* Gross. */
+ printf("Lk %.*s", (int)((dsz > 1 ? realend - 1 :
+ realend) - linkstart), &buf[linkstart]);
return(1);
}
/* See if we qualify as a mailto. */
- if (j > 7 && 0 == memcmp("mailto:", &buf[linkstart], j)) {
+ if (j > 6 && 0 == memcmp("mailto:", &buf[linkstart], j)) {
printf("Mt %.*s", (int)j, &buf[linkstart]);
return(1);
}
Index: pod2mdoc.1
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/pod2mdoc/pod2mdoc.1,v
retrieving revision 1.9
retrieving revision 1.10
diff -Lpod2mdoc.1 -Lpod2mdoc.1 -u -p -r1.9 -r1.10
--- pod2mdoc.1
+++ pod2mdoc.1
@@ -182,6 +182,10 @@ manpage in section 3P if containing doub
otherwise.
The section may be overriden as
.Li L<foo(5)> .
+If only a section appears, such as in
+.Li </section> ,
+the link is rendered with
+.Sq \&Sx .
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
@@ -248,3 +252,7 @@ will cause the second space to be lost.
The
.Li S<>
escape is discarded.
+.Pp
+Unless solely a section link, the text and section parts of
+.Li L<text|link/section>
+are discarded.
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2014-04-03 11:34 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=201404031134.s33BYUIQ026125@krisdoz.my.domain \
--to=kristaps@mdocml.bsd.lv \
--cc=source@mdocml.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).