summaryrefslogtreecommitdiffstats
path: root/src/markdown.cpp
diff options
context:
space:
mode:
authorChristoph Lipka <c-lipka@users.noreply.github.com>2016-04-30 15:48:37 (GMT)
committerChristoph Lipka <c-lipka@users.noreply.github.com>2016-04-30 15:48:37 (GMT)
commit7e564896fcc41c2b1a6bd5c86ebebab0de7ea5f9 (patch)
treece23ec5c400c8405f595f45635b00290da4ddece /src/markdown.cpp
parentd6952dc609f22553c779034a9769c55e22f4194d (diff)
downloadDoxygen-7e564896fcc41c2b1a6bd5c86ebebab0de7ea5f9.zip
Doxygen-7e564896fcc41c2b1a6bd5c86ebebab0de7ea5f9.tar.gz
Doxygen-7e564896fcc41c2b1a6bd5c86ebebab0de7ea5f9.tar.bz2
Added an option to add "anonymous" headings to the table of contents (currently Markdown only).
Diffstat (limited to 'src/markdown.cpp')
-rw-r--r--src/markdown.cpp16
1 files changed, 12 insertions, 4 deletions
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;
}