From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s33BYUCV018398 for ; Thu, 3 Apr 2014 07:34:30 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s33BYUIQ026125; Thu, 3 Apr 2014 07:34:30 -0400 (EDT) Date: Thu, 3 Apr 2014 07:34:30 -0400 (EDT) Message-Id: <201404031134.s33BYUIQ026125@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: pod2mdoc: Account for sections as well as links. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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 . +If only a section appears, such as in +.Li , +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 +are discarded. -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv