Permalink
Browse files

Added an option to add "anonymous" headings to the table of contents …

…(currently Markdown only).
  • Loading branch information...
c-lipka committed Apr 30, 2016
1 parent d6952dc commit 7e564896fcc41c2b1a6bd5c86ebebab0de7ea5f9
Showing with 23 additions and 4 deletions.
  1. +1 −0 Doxyfile
  2. +10 −0 src/config.xml
  3. +12 −4 src/markdown.cpp
View
@@ -35,6 +35,7 @@ OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
EXTENSION_MAPPING =
MARKDOWN_SUPPORT = YES
TOC_INCLUDE_HEADINGS =
AUTOLINK_SUPPORT = YES
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
View
@@ -614,6 +614,16 @@ Go to the <a href="commands.html">next</a> section or return to the
The output of markdown processing is further processed by doxygen, so you
can mix doxygen, HTML, and XML commands with Markdown formatting.
Disable only in case of backward compatibilities issues.
]]>
</docs>
</option>
<option type='int' id='TOC_INCLUDE_HEADINGS' minval='0' maxval='99' defval='0' depends='MARKDOWN_SUPPORT'>
<docs>
<![CDATA[
When the \c TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings
up to that level are automatically included in the table of contents, even if
they do not have an id attribute.
\note This feature currently applies only to Markdown headings.
]]>
</docs>
</option>
View
@@ -1226,7 +1226,7 @@ static int isHRuler(const char *data,int size)
return n>=3; // at least 3 characters needed for a hruler
}
static QCString extractTitleId(QCString &title)
static QCString extractTitleId(QCString &title, int level)
{
//static QRegExp r1("^[a-z_A-Z][a-z_A-Z0-9\\-]*:");
static QRegExp r2("\\{#[a-z_A-Z][a-z_A-Z0-9\\-]*\\}");
@@ -1239,6 +1239,14 @@ static QCString extractTitleId(QCString &title)
//printf("found id='%s' title='%s'\n",id.data(),title.data());
return id;
}
if ((level > 0) && (level <= Config_getInt(TOC_INCLUDE_HEADINGS)))
{
static int autoId = 0;
QCString id;
id.sprintf("autotoc_md%d",autoId++);
//printf("auto-generated id='%s' title='%s'\n",id.data(),title.data());
return id;
}
//printf("no id found in title '%s'\n",title.data());
return "";
}
@@ -1270,7 +1278,7 @@ static int isAtxHeader(const char *data,int size,
// store result
convertStringFragment(header,data+i,end-i);
id = extractTitleId(header);
id = extractTitleId(header, level);
if (!id.isEmpty()) // strip #'s between title and id
{
i=header.length()-1;
@@ -2079,7 +2087,7 @@ static QCString processBlocks(const QCString &s,int indent)
while (pi<size && data[pi]==' ') pi++;
QCString header,id;
convertStringFragment(header,data+pi,i-pi-1);
id = extractTitleId(header);
id = extractTitleId(header, level);
//printf("header='%s' is='%s'\n",header.data(),id.data());
if (!header.isEmpty())
{
@@ -2220,7 +2228,7 @@ static QCString extractPageTitle(QCString &docs,QCString &id)
QCString lns;
lns.fill('\n',ln);
docs=lns+docs.mid(end2);
id = extractTitleId(title);
id = extractTitleId(title, 0);
//printf("extractPageTitle(title='%s' docs='%s' id='%s')\n",title.data(),docs.data(),id.data());
return title;
}

0 comments on commit 7e56489

Please sign in to comment.