summaryrefslogtreecommitdiffstats
path: root/src/markdown.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2014-03-17 20:33:49 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2014-03-17 20:33:49 (GMT)
commit3598e8fdf7ee61a281480fec09f63669710ac35d (patch)
tree359d87a8c551f725b4b852034f335ca85b0f9ccf /src/markdown.cpp
parentfdc81edcd47ce176648d7507d0597294098ae8aa (diff)
downloadDoxygen-3598e8fdf7ee61a281480fec09f63669710ac35d.zip
Doxygen-3598e8fdf7ee61a281480fec09f63669710ac35d.tar.gz
Doxygen-3598e8fdf7ee61a281480fec09f63669710ac35d.tar.bz2
Bug 726294 - Markdown Extra - fenced code block: '>' before tab width parsed as block quote
Diffstat (limited to 'src/markdown.cpp')
-rw-r--r--src/markdown.cpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp
index 9605f31..98b06f4 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -1925,12 +1925,29 @@ static void findEndOfLine(GrowBuf &out,const char *data,int size,
//printf("findEndOfLine pi=%d i=%d end=%d {%s}\n",pi,i,end,QCString(data+i).left(end-i).data());
}
+static void writeFencedCodeBlock(GrowBuf &out,const char *data,const char *lng,
+ int blockStart,int blockEnd)
+{
+ QCString lang = lng;
+ if (!lang.isEmpty() && lang.at(0)=='.') lang=lang.mid(1);
+ out.addStr("@code");
+ if (!lang.isEmpty())
+ {
+ out.addStr("{"+lang+"}");
+ }
+ out.addStr(data+blockStart,blockEnd-blockStart);
+ out.addStr("\n");
+ out.addStr("@endcode");
+}
+
static QCString processQuotations(const QCString &s,int refIndent)
{
GrowBuf out;
const char *data = s.data();
int size = s.length();
int i=0,end=0,pi=-1;
+ int blockStart,blockEnd,blockOffset;
+ QCString lang;
while (i<size)
{
findEndOfLine(out,data,size,pi,i,end);
@@ -1938,7 +1955,15 @@ static QCString processQuotations(const QCString &s,int refIndent)
if (pi!=-1)
{
- if (isBlockQuote(data+pi,i-pi,refIndent))
+ if (isFencedCodeBlock(data+pi,size-pi,refIndent,lang,blockStart,blockEnd,blockOffset))
+ {
+ writeFencedCodeBlock(out,data+pi,lang,blockStart,blockEnd);
+ i=pi+blockOffset;
+ pi=-1;
+ end=i+1;
+ continue;
+ }
+ else if (isBlockQuote(data+pi,i-pi,refIndent))
{
i = pi+writeBlockQuote(out,data+pi,size-pi);
pi=-1;
@@ -2089,15 +2114,7 @@ static QCString processBlocks(const QCString &s,int indent)
{
//printf("Found FencedCodeBlock lang='%s' start=%d end=%d code={%s}\n",
// lang.data(),blockStart,blockEnd,QCString(data+pi+blockStart).left(blockEnd-blockStart).data());
- if (!lang.isEmpty() && lang.at(0)=='.') lang=lang.mid(1);
- out.addStr("@code");
- if (!lang.isEmpty())
- {
- out.addStr("{"+lang+"}");
- }
- out.addStr(data+pi+blockStart,blockEnd-blockStart);
- out.addStr("\n");
- out.addStr("@endcode");
+ writeFencedCodeBlock(out,data+pi,lang,blockStart,blockEnd);
i=pi+blockOffset;
pi=-1;
end=i+1;