diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-06-02 10:34:13 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2019-06-02 10:34:13 (GMT) |
commit | a8b46600830be24ac189f798a1915f0ad1b86beb (patch) | |
tree | 310e15cf32ca7a090eafd46261d80e343783e1cc /src | |
parent | 7b745c4b8182430d3eacde1cb1520730fee1b01e (diff) | |
download | Doxygen-a8b46600830be24ac189f798a1915f0ad1b86beb.zip Doxygen-a8b46600830be24ac189f798a1915f0ad1b86beb.tar.gz Doxygen-a8b46600830be24ac189f798a1915f0ad1b86beb.tar.bz2 |
Bug 757574 - Warning regarding subsection with anchor in markdown
Diffstat (limited to 'src')
-rw-r--r-- | src/markdown.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp index c73324a..15f119b 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -1097,7 +1097,7 @@ static void processInline(GrowBuf &out,const char *data,int size) } /** returns whether the line is a setext-style hdr underline */ -static int isHeaderline(const char *data, int size) +static int isHeaderline(const char *data, int size, bool allowAdjustLevel) { int i=0, c=0; while (i<size && data[i]==' ') i++; @@ -1107,7 +1107,17 @@ static int isHeaderline(const char *data, int size) { while (i<size && data[i]=='=') i++,c++; while (i<size && data[i]==' ') i++; - return (c>1 && (i>=size || data[i]=='\n')) ? g_indentLevel+1 : 0; + int level = (c>1 && (i>=size || data[i]=='\n')) ? 1 : 0; + if (allowAdjustLevel && level==1 && g_indentLevel==-1) + { + // In case a page starts with a header line we use it as title, promoting it to @page. + // We set g_indentLevel to -1 to promoting the other sections if they have a deeper + // nesting level than the page header, i.e. @section..@subsection becomes @page..@section. + // In case a section at the same level is found (@section..@section) however we need + // to undo this (and the result will be @page..@section). + g_indentLevel=0; + } + return g_indentLevel+level; } // test of level 2 header if (data[i]=='-') @@ -2272,7 +2282,7 @@ static QCString processBlocks(const QCString &s,int indent) QCString lang; blockIndent = indent; //printf("isHeaderLine(%s)=%d\n",QCString(data+i).left(size-i).data(),level); - if ((level=isHeaderline(data+i,size-i))>0) + if ((level=isHeaderline(data+i,size-i,TRUE))>0) { //printf("Found header at %d-%d\n",i,end); while (pi<size && data[pi]==' ') pi++; @@ -2414,7 +2424,7 @@ static QCString extractPageTitle(QCString &docs,QCString &id) // second line form end1..end2 int end2=end1+1; while (end2<size && data[end2-1]!='\n') end2++; - if (isHeaderline(data+end1,size-end1)) + if (isHeaderline(data+end1,size-end1,FALSE)) { convertStringFragment(title,data+i,end1-i-1); QCString lns; |