summaryrefslogtreecommitdiffstats
path: root/src/markdown.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2012-05-19 12:11:23 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2012-05-19 12:11:23 (GMT)
commit55e5055cfbb6f8e013a894c0ec8b10771231e3ba (patch)
tree58d7a64919b99cc76fdc7120ae5d0407f3163a67 /src/markdown.cpp
parent44ca9512aaeb19f7fbd07afda88ec4cfe53ce831 (diff)
downloadDoxygen-55e5055cfbb6f8e013a894c0ec8b10771231e3ba.zip
Doxygen-55e5055cfbb6f8e013a894c0ec8b10771231e3ba.tar.gz
Doxygen-55e5055cfbb6f8e013a894c0ec8b10771231e3ba.tar.bz2
Release-1.8.1
Diffstat (limited to 'src/markdown.cpp')
-rw-r--r--src/markdown.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp
index 6faeddf..bb1a5a3 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -976,22 +976,22 @@ static void processInline(GrowBuf &out,const char *data,int size)
/** returns whether the line is a setext-style hdr underline */
static int isHeaderline(const char *data, int size)
{
- int i = 0;
+ int i=0, c=0;
while (i<size && data[i]==' ') i++;
// test of level 1 header
if (data[i]=='=')
{
- while (i<size && data[i]=='=') i++;
+ while (i<size && data[i]=='=') i++,c++;
while (i<size && data[i]==' ') i++;
- return (i>=size || data[i]=='\n') ? 1 : 0;
+ return (c>1 && (i>=size || data[i]=='\n')) ? 1 : 0;
}
// test of level 2 header
if (data[i]=='-')
{
- while (i<size && data[i]=='-') i++;
+ while (i<size && data[i]=='-') i++,c++;
while (i<size && data[i]==' ') i++;
- return (i>=size || data[i]=='\n') ? 2 : 0;
+ return (c>1 && (i>=size || data[i]=='\n')) ? 2 : 0;
}
return 0;
}
@@ -1713,6 +1713,7 @@ static int writeCodeBlock(GrowBuf &out,const char *data,int size,int refIndent)
int i=0,end;
//printf("writeCodeBlock: data={%s}\n",QCString(data).left(size).data());
out.addStr("@verbatim\n");
+ int emptyLines=0;
while (i<size)
{
// find end of this line
@@ -1724,12 +1725,17 @@ static int writeCodeBlock(GrowBuf &out,const char *data,int size,int refIndent)
//printf("j=%d end=%d indent=%d refIndent=%d data={%s}\n",j,end,indent,refIndent,QCString(data+i).left(end-i-1).data());
if (j==end-1) // empty line
{
- // add empty line
- out.addStr("\n");
+ emptyLines++;
i=end;
}
else if (indent>=refIndent+codeBlockIndent) // enough indent to contine the code block
{
+ while (emptyLines>0) // write skipped empty lines
+ {
+ // add empty line
+ out.addStr("\n");
+ emptyLines--;
+ }
// add code line minus the indent
out.addStr(data+i+refIndent+codeBlockIndent,end-i-refIndent-codeBlockIndent);
i=end;
@@ -1740,6 +1746,12 @@ static int writeCodeBlock(GrowBuf &out,const char *data,int size,int refIndent)
}
}
out.addStr("@endverbatim\n");
+ while (emptyLines>0) // write skipped empty lines
+ {
+ // add empty line
+ out.addStr("\n");
+ emptyLines--;
+ }
//printf("i=%d\n",i);
return i;
}