diff --git a/src/markdown.cpp b/src/markdown.cpp index 8369d66a453..87d2c01628f 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -107,13 +107,7 @@ static action_t g_actions[256]; static Entry *g_current; static QCString g_fileName; static int g_lineNr; - -// In case a markdown page starts with a level1 header, that header is used -// as a title of the page, in effect making it a level0 header, so the -// level of all other sections needs to be corrected as well. -// This flag is TRUE if corrections are needed. -//static bool g_correctSectionLevel; - +static int g_indentLevel=0; // 0 is outside markdown, -1=page level //---------- @@ -1113,14 +1107,14 @@ static int isHeaderline(const char *data, int size) { while (i1 && (i>=size || data[i]=='\n')) ? 1 : 0; + return (c>1 && (i>=size || data[i]=='\n')) ? g_indentLevel+1 : 0; } // test of level 2 header if (data[i]=='-') { while (i1 && (i>=size || data[i]=='\n')) ? 2 : 0; + return (c>1 && (i>=size || data[i]=='\n')) ? g_indentLevel+2 : 0; } return 0; } @@ -1328,7 +1322,7 @@ static int isAtxHeader(const char *data,int size, header=header.left(i+1); } - return level; + return level+g_indentLevel; } static int isEmptyLine(const char *data,int size) @@ -1915,8 +1909,6 @@ void writeOneLineHeaderOrRuler(GrowBuf &out,const char *data,int size) } else if ((level=isAtxHeader(data,size,header,id))) { - //if (level==1) g_correctSectionLevel=FALSE; - //if (g_correctSectionLevel) level--; QCString hTag; if (level<5 && !id.isEmpty()) { @@ -2260,8 +2252,6 @@ static QCString processBlocks(const QCString &s,int indent) //printf("isHeaderLine(%s)=%d\n",QCString(data+i).left(size-i).data(),level); if ((level=isHeaderline(data+i,size-i))>0) { - //if (level==1) g_correctSectionLevel=FALSE; - //if (g_correctSectionLevel) level--; //printf("Found header at %d-%d\n",i,end); while (pi