Update markdown anchors to use "title-of-heading" format.

pull/196/head
Michael Sweet 7 years ago
parent 1146488efb
commit 8bdacd119d
  1. 2
      doc/mxml.man
  2. 6
      mmd.c
  3. 9
      mxmldoc.c

@ -1,4 +1,4 @@
.TH mxml 3 "Mini-XML API" "05/01/17" "Mini-XML API" .TH mxml 3 "Mini-XML API" "05/02/17" "Mini-XML API"
.SH NAME .SH NAME
mxml \- Mini-XML API mxml \- Mini-XML API
.SH INCLUDE FILE .SH INCLUDE FILE

@ -706,7 +706,7 @@ mmd_parse_inline(mmd_t *parent, /* I - Parent node */
whitespace = 1; whitespace = 1;
} }
else if (*lineptr == '!' && lineptr[1] == '[') else if (*lineptr == '!' && lineptr[1] == '[' && type != MMD_TYPE_CODE_TEXT)
{ {
/* /*
* Image... * Image...
@ -732,7 +732,7 @@ mmd_parse_inline(mmd_t *parent, /* I - Parent node */
whitespace = 0; whitespace = 0;
lineptr --; lineptr --;
} }
else if (*lineptr == '[') else if (*lineptr == '[' && type != MMD_TYPE_CODE_TEXT)
{ {
/* /*
* Link... * Link...
@ -768,7 +768,7 @@ mmd_parse_inline(mmd_t *parent, /* I - Parent node */
whitespace = 0; whitespace = 0;
lineptr --; lineptr --;
} }
else if (*lineptr == '<' && strchr(lineptr + 1, '>')) else if (*lineptr == '<' && type != MMD_TYPE_CODE_TEXT && strchr(lineptr + 1, '>'))
{ {
/* /*
* Autolink... * Autolink...

@ -1436,7 +1436,9 @@ markdown_anchor(const char *text) /* I - Title text */
for (bufptr = buffer; *text && bufptr < (buffer + sizeof(buffer) - 1); text ++) for (bufptr = buffer; *text && bufptr < (buffer + sizeof(buffer) - 1); text ++)
{ {
if ((*text >= '0' && *text <= '9') || (*text >= 'a' && *text <= 'z') || (*text >= 'A' && *text <= 'Z') || *text == '.' || *text == '-') if ((*text >= '0' && *text <= '9') || (*text >= 'a' && *text <= 'z') || (*text >= 'A' && *text <= 'Z') || *text == '.' || *text == '-')
*bufptr++ = *text; *bufptr++ = (char)tolower(*text);
else if (*text == ' ')
*bufptr++ = '-';
} }
*bufptr = '\0'; *bufptr = '\0';
@ -1597,7 +1599,12 @@ markdown_write_block(FILE *out, /* I - Output file */
fprintf(out, " <%s><a id=\"", element); fprintf(out, " <%s><a id=\"", element);
for (node = mmdGetFirstChild(parent); node; node = mmdGetNextSibling(node)) for (node = mmdGetFirstChild(parent); node; node = mmdGetNextSibling(node))
{
if (mmdGetWhitespace(node))
fputc('-', out);
fputs(markdown_anchor(mmdGetText(node)), out); fputs(markdown_anchor(mmdGetText(node)), out);
}
fputs("\">", out); fputs("\">", out);
} }
else if (element) else if (element)

Loading…
Cancel
Save