Skip to content

Commit d73d1a4

Browse files
committed
issue #10902 Improve Markdown Support - blockquotes with special markers parse wrongly (2)
Based on the discussion in the issue it is better that directly after the "GitHub Markdown style alerts" there is only 1 `<br>` in case of an "empty line"
1 parent 4d93134 commit d73d1a4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/markdown.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2712,6 +2712,7 @@ size_t Markdown::Private::writeBlockQuote(std::string_view data)
27122712
const size_t size = data.size();
27132713
QCString startCmd;
27142714
int isGitHubAlert = false;
2715+
int isGitHubFirst = false;
27152716
while (i<size)
27162717
{
27172718
// find end of this line
@@ -2742,26 +2743,31 @@ size_t Markdown::Private::writeBlockQuote(std::string_view data)
27422743
if (txt == "[!note]")
27432744
{
27442745
isGitHubAlert = true;
2746+
isGitHubFirst = true;
27452747
startCmd = "\\note ";
27462748
}
27472749
else if (txt == "[!warning]")
27482750
{
27492751
isGitHubAlert = true;
2752+
isGitHubFirst = true;
27502753
startCmd = "\\warning ";
27512754
}
27522755
else if (txt == "[!tip]")
27532756
{
27542757
isGitHubAlert = true;
2758+
isGitHubFirst = true;
27552759
startCmd = "\\remark ";
27562760
}
27572761
else if (txt == "[!caution]")
27582762
{
27592763
isGitHubAlert = true;
2764+
isGitHubFirst = true;
27602765
startCmd = "\\attention ";
27612766
}
27622767
else if (txt == "[!important]")
27632768
{
27642769
isGitHubAlert = true;
2770+
isGitHubFirst = true;
27652771
startCmd = "\\important ";
27662772
}
27672773
}
@@ -2790,8 +2796,13 @@ size_t Markdown::Private::writeBlockQuote(std::string_view data)
27902796
if (curLevel != 0 || !isGitHubAlert)
27912797
{
27922798
QCString txt = data.substr(indent,end-indent);
2793-
if (txt.stripWhiteSpace().isEmpty() && !startCmd.isEmpty()) out += "<br><br>\n";
2799+
if (txt.stripWhiteSpace().isEmpty() && !startCmd.isEmpty())
2800+
{
2801+
if (!isGitHubFirst) out += "<br>";
2802+
out += "<br>\n";
2803+
}
27942804
else out += txt;
2805+
isGitHubFirst = false;
27952806
}
27962807
else out+= "\n";
27972808
curLevel=level;

0 commit comments

Comments
 (0)