From 7b2e841b3a3d7d787458f236e2447c890cfbf590 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Tue, 15 Dec 2020 21:24:50 +0100 Subject: issue #8251: Macro stopped working in 1.8,.19 --- src/markdown.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/markdown.cpp b/src/markdown.cpp index 33a471a..0cf8b87 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -1693,7 +1693,12 @@ static bool isCodeBlock(const char *data,int offset,int size,int &indent) // search back 3 lines and remember the start of lines -1 and -2 while (i>0 && nl<3) { - if (data[i-offset-1]=='\n') nl_pos[nl++]=i-offset; + int j = i-offset-1; + int nl_size = isNewline(data+j); + if (nl_size>0) + { + nl_pos[nl++]=j+nl_size; + } i--; } @@ -1717,8 +1722,8 @@ static bool isCodeBlock(const char *data,int offset,int size,int &indent) // determine the indent of line -2 indent=computeIndentExcludingListMarkers(data+nl_pos[2],nl_pos[1]-nl_pos[2]); - //printf(">isCodeBlock local_indent %d>=%d+4=%d\n", - // indent0,indent2,indent0>=indent2+4); + //printf(">isCodeBlock local_indent %d>=%d+%d=%d\n", + // indent0,indent,codeBlockIndent,indent0>=indent+codeBlockIndent); // if the difference is >4 spaces -> code block return indent0>=indent+codeBlockIndent; } @@ -2152,7 +2157,7 @@ int Markdown::writeCodeBlock(const char *data,int size,int refIndent) TRACE(data); int i=0,end; //printf("writeCodeBlock: data={%s}\n",QCString(data).left(size).data()); - // no need for \ilinebr here as the prvious like was empty and was skipped + // no need for \ilinebr here as the previous line was empty and was skipped m_out.addStr("@verbatim\n"); int emptyLines=0; while (i