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

This commit is contained in:
Michael Sweet 2017-05-02 09:06:55 -04:00
parent 1146488efb
commit 8bdacd119d
3 changed files with 12 additions and 5 deletions

View File

@ -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
mxml \- Mini-XML API
.SH INCLUDE FILE

6
mmd.c
View File

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

View File

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