diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-05-27 19:42:14 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2019-05-27 19:42:14 (GMT) |
commit | 8625ec5da0a505caf2dcfd16a5a8c1e668633ca8 (patch) | |
tree | ba422a59cb48128ead62c43818068bd11f6931de /src | |
parent | f40468618d8bd750c73c31592662fcf174a717a1 (diff) | |
download | Doxygen-8625ec5da0a505caf2dcfd16a5a8c1e668633ca8.zip Doxygen-8625ec5da0a505caf2dcfd16a5a8c1e668633ca8.tar.gz Doxygen-8625ec5da0a505caf2dcfd16a5a8c1e668633ca8.tar.bz2 |
Bug 757574 - Warning regarding subsection with anchor in markdown
Diffstat (limited to 'src')
-rw-r--r-- | src/markdown.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp index 87d2c01..c73324a 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -1289,7 +1289,7 @@ static QCString extractTitleId(QCString &title, int level) static int isAtxHeader(const char *data,int size, - QCString &header,QCString &id) + QCString &header,QCString &id,bool allowAdjustLevel) { int i = 0, end; int level = 0, blanks=0; @@ -1322,6 +1322,28 @@ static int isAtxHeader(const char *data,int size, header=header.left(i+1); } + if (allowAdjustLevel && level==1 && g_indentLevel==-1) + { + // in case we find a `# Section` on a markdown page that started with the same level + // header, we no longer need to artificially decrease the paragraph level. + // So both + // ------------------- + // # heading 1 <-- here we set g_indentLevel to -1 + // # heading 2 <-- here we set g_indentLevel back to 0 such that this will be a @section + // ------------------- + // and + // ------------------- + // # heading 1 <-- here we set g_indentLevel to -1 + // ## heading 2 <-- here we keep g_indentLevel at -1 such that @subsection will be @section + // ------------------- + // will convert to + // ------------------- + // @page md_page Heading 1 + // @section autotoc_md1 Heading 2 + // ------------------- + + g_indentLevel=0; + } return level+g_indentLevel; } @@ -1907,7 +1929,7 @@ void writeOneLineHeaderOrRuler(GrowBuf &out,const char *data,int size) { out.addStr("\n<hr>\n"); } - else if ((level=isAtxHeader(data,size,header,id))) + else if ((level=isAtxHeader(data,size,header,id,TRUE))) { QCString hTag; if (level<5 && !id.isEmpty()) @@ -2403,7 +2425,7 @@ static QCString extractPageTitle(QCString &docs,QCString &id) return title; } } - if (i<end1 && isAtxHeader(data+i,end1-i,title,id)>0) + if (i<end1 && isAtxHeader(data+i,end1-i,title,id,FALSE)>0) { docs=docs.mid(end1); } |