=================================================================== RCS file: /cvs/pod2mdoc/pod2mdoc.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -p -r1.22 -r1.23 --- pod2mdoc/pod2mdoc.c 2014/04/03 16:50:32 1.22 +++ pod2mdoc/pod2mdoc.c 2014/04/07 11:46:03 1.23 @@ -1,4 +1,4 @@ -/* $Id: pod2mdoc.c,v 1.22 2014/04/03 16:50:32 kristaps Exp $ */ +/* $Id: pod2mdoc.c,v 1.23 2014/04/07 11:46:03 kristaps Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * @@ -187,12 +187,18 @@ trylink(const char *buf, size_t *start, size_t end, si * Scan to the start of the terminus. * This function is more or less replicated in the formatcode() * for null or index formatting codes. + * However, we're slightly different because we might have + * nested escapes we need to ignore. */ stack = 0; for (linkstart = realend = *start; realend < end; realend++) { + if ('<' == buf[realend]) + stack++; if ('>' != buf[realend]) continue; - else if (dsz == 1) + else if (stack-- > 0) + continue; + if (dsz == 1) break; assert(realend > 0); if (' ' != buf[realend - 1])