Skip to content

Commit 9b709ad

Browse files
authored
Merge pull request doxygen#11865 from albert-github/feature/issue_11863
issue doxygen#11863 parse of markdown does not exclude Code blocks
2 parents 6533fec + 855a7f9 commit 9b709ad

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/markdown.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,8 @@ static bool isEndOfList(std::string_view data)
23272327
}
23282328

23292329
static bool isFencedCodeBlock(std::string_view data,size_t refIndent,
2330-
QCString &lang,size_t &start,size_t &end,size_t &offset)
2330+
QCString &lang,size_t &start,size_t &end,size_t &offset,
2331+
QCString &fileName,int lineNr)
23312332
{
23322333
AUTO_TRACE("data='{}' refIndent={}",Trace::trunc(data),refIndent);
23332334
const char dot = '.';
@@ -2419,6 +2420,7 @@ static bool isFencedCodeBlock(std::string_view data,size_t refIndent,
24192420
}
24202421
i++;
24212422
}
2423+
warn(fileName, lineNr, "Ending Inside a fenced code block. Maybe the end marker for the block is missing?");
24222424
AUTO_TRACE_EXIT("result=false: no end marker found lang={}'",lang);
24232425
return false;
24242426
}
@@ -3277,7 +3279,7 @@ QCString Markdown::Private::processQuotations(std::string_view data,size_t refIn
32773279
if (pi!=std::string::npos)
32783280
{
32793281
size_t blockStart=0, blockEnd=0, blockOffset=0;
3280-
if (isFencedCodeBlock(data.substr(pi),currentIndent,lang,blockStart,blockEnd,blockOffset))
3282+
if (isFencedCodeBlock(data.substr(pi),currentIndent,lang,blockStart,blockEnd,blockOffset,fileName,lineNr))
32813283
{
32823284
auto addSpecialCommand = [&](const QCString &startCmd,const QCString &endCmd)
32833285
{
@@ -3368,6 +3370,10 @@ QCString Markdown::Private::processQuotations(std::string_view data,size_t refIn
33683370
}
33693371
else
33703372
{
3373+
if (QCString(data.substr(pi)).startsWith("```") || QCString(data.substr(pi)).startsWith("~~~"))
3374+
{
3375+
warn(fileName, lineNr, "Ending inside a fenced code block. Maybe the end marker for the block is missing?");
3376+
}
33713377
out+=data.substr(pi);
33723378
}
33733379
}
@@ -3532,7 +3538,7 @@ QCString Markdown::Private::processBlocks(std::string_view data,const size_t ind
35323538
i=ref+pi;
35333539
end=i+1;
35343540
}
3535-
else if (isFencedCodeBlock(data.substr(pi),currentIndent,lang,blockStart,blockEnd,blockOffset))
3541+
else if (isFencedCodeBlock(data.substr(pi),currentIndent,lang,blockStart,blockEnd,blockOffset,fileName,lineNr))
35363542
{
35373543
//printf("Found FencedCodeBlock lang='%s' start=%d end=%d code={%s}\n",
35383544
// qPrint(lang),blockStart,blockEnd,QCString(data+pi+blockStart).left(blockEnd-blockStart).data());

0 commit comments

Comments
 (0)