summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-10-17 10:54:48 (GMT)
committerGitHub <noreply@github.com>2020-10-17 10:54:48 (GMT)
commit111905bdbc511434bd909f8f8dc0cf6c63620d43 (patch)
tree5db15fe965eccca8eeadc60bfd937d71a1640713
parentc72f5e0ae81a547082228c03688659c7c22c3991 (diff)
parent927af4b61fc3bac384aeca0d04ef321c854b3ef0 (diff)
downloadDoxygen-111905bdbc511434bd909f8f8dc0cf6c63620d43.zip
Doxygen-111905bdbc511434bd909f8f8dc0cf6c63620d43.tar.gz
Doxygen-111905bdbc511434bd909f8f8dc0cf6c63620d43.tar.bz2
Merge pull request #8111 from albert-github/feature/bug_cnt_md_links
Miscounting in case of markdown links
-rw-r--r--src/markdown.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp
index 15e18bc..c72537b 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -808,6 +808,7 @@ int Markdown::processLink(const char *data,int,int size)
}
contentStart=i;
int level=1;
+ int nlTotal=0;
int nl=0;
// find the matching ]
while (i<size)
@@ -831,6 +832,8 @@ int Markdown::processLink(const char *data,int,int size)
}
i++;
}
+ nlTotal += nl;
+ nl = 0;
if (i>=size) return 0; // premature end of comment -> no link
contentEnd=i;
convertStringFragment(content,data+contentStart,contentEnd-contentStart);
@@ -843,9 +846,12 @@ int Markdown::processLink(const char *data,int,int size)
if (i<size && data[i]=='\n') // one newline allowed here
{
i++;
+ nl++;
// skip more whitespace
while (i<size && data[i]==' ') i++;
}
+ nlTotal += nl;
+ nl = 0;
bool explicitTitle=FALSE;
if (i<size && data[i]=='(') // inline link
@@ -854,7 +860,6 @@ int Markdown::processLink(const char *data,int,int size)
while (i<size && data[i]==' ') i++;
if (i<size && data[i]=='<') i++;
linkStart=i;
- nl=0;
int braceCount=1;
while (i<size && data[i]!='\'' && data[i]!='"' && braceCount>0)
{
@@ -876,6 +881,8 @@ int Markdown::processLink(const char *data,int,int size)
i++;
}
}
+ nlTotal += nl;
+ nl = 0;
if (i>=size || data[i]=='\n') return 0;
convertStringFragment(link,data+linkStart,i-linkStart);
link = link.stripWhiteSpace();
@@ -985,6 +992,8 @@ int Markdown::processLink(const char *data,int,int size)
{
return 0;
}
+ nlTotal += nl;
+ nl = 0;
if (isToc) // special case for [TOC]
{
int toc_level = Config_getInt(TOC_INCLUDE_HEADINGS);
@@ -1066,6 +1075,7 @@ int Markdown::processLink(const char *data,int,int size)
m_out.addStr("<a href=\"");
m_out.addStr(link);
m_out.addStr("\"");
+ for (int i = 0; i < nlTotal; i++) m_out.addStr("\n");
if (!title.isEmpty())
{
m_out.addStr(" title=\"");