summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doxyfile1
-rw-r--r--src/config.xml10
-rw-r--r--src/markdown.cpp16
3 files changed, 23 insertions, 4 deletions
diff --git a/Doxyfile b/Doxyfile
index 325a875..82a57b7 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -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
diff --git a/src/config.xml b/src/config.xml
index 0aa8fda..69b13ec 100644
--- a/src/config.xml
+++ b/src/config.xml
@@ -617,6 +617,16 @@ Go to the <a href="commands.html">next</a> section or return to the
]]>
</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>
<option type='bool' id='AUTOLINK_SUPPORT' defval='1'>
<docs>
<![CDATA[
diff --git a/src/markdown.cpp b/src/markdown.cpp
index 9bee243..a071857 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -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;
}