From bf1e768aa86ac5cbca5de4510469dd98334973df Mon Sep 17 00:00:00 2001
From: albert-github
Date: Sat, 19 Jan 2019 18:45:26 +0100
Subject: issue #6781 Unable to use math in markdown table headers
Due to the change of the place where the markdown processing is done the end of the line must be calculated a little bit differently.
Note: translator.py gave an error due to a strange indentation (did surface now), so had to be corrected as well.
---
doc/translator.py | 6 +++---
src/markdown.cpp | 36 ++++++++++++------------------------
2 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/doc/translator.py b/doc/translator.py
index 2246c08..ed001bb 100644
--- a/doc/translator.py
+++ b/doc/translator.py
@@ -1821,9 +1821,9 @@ class TrManager:
tplDic['numLangStr'] = str(self.numLang)
# Define templates for HTML table parts of the documentation.
- htmlTableTpl = '''\
+ htmlTableTpl = '''
\\htmlonly
-
+
@@ -1842,7 +1842,7 @@ class TrManager:
|
-
+
\\endhtmlonly
'''
htmlTableTpl = textwrap.dedent(htmlTableTpl)
diff --git a/src/markdown.cpp b/src/markdown.cpp
index fcad7e9..7ef55bf 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -523,7 +523,7 @@ static int processQuoted(GrowBuf &out,const char *data,int,int size)
/** Process a HTML tag. Note that
..
are treated specially, in
* the sense that all code inside is written unprocessed
*/
-static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
+static int processHtmlTagWrite(GrowBuf &out,const char *data,int offset,int size,bool doWrite)
{
if (offset>0 && data[-1]=='\\') return 0; // escaped <
@@ -546,7 +546,7 @@ static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
tolower(data[i+2])=='p' && tolower(data[i+3])=='r' &&
tolower(data[i+4])=='e' && tolower(data[i+5])=='>')
{ // found tag, copy from start to end of tag
- out.addStr(data,i+6);
+ if (doWrite) out.addStr(data,i+6);
//printf("found ..
[%d..%d]\n",0,i+6);
return i+6;
}
@@ -569,13 +569,13 @@ static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
if (data[i]=='/' && i') //
{
//printf("Found htmlTag={%s}\n",QCString(data).left(i+2).data());
- out.addStr(data,i+2);
+ if (doWrite) out.addStr(data,i+2);
return i+2;
}
else if (data[i]=='>') //
{
//printf("Found htmlTag={%s}\n",QCString(data).left(i+1).data());
- out.addStr(data,i+1);
+ if (doWrite) out.addStr(data,i+1);
return i+1;
}
else if (data[i]==' ') // ') // found end of tag
{
//printf("Found htmlTag={%s}\n",QCString(data).left(i+1).data());
- out.addStr(data,i+1);
+ if (doWrite) out.addStr(data,i+1);
return i+1;
}
i++;
@@ -606,6 +606,10 @@ static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
//printf("Not a valid html tag\n");
return 0;
}
+static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
+{
+ return processHtmlTagWrite(out,data,offset,size,true);
+}
static int processEmphasis(GrowBuf &out,const char *data,int offset,int size)
{
@@ -2086,17 +2090,9 @@ static void findEndOfLine(GrowBuf &out,const char *data,int size,
{
if (qstrncmp(&data[end+1],endBlockName,l)==0)
{
- if (pi!=-1) // output previous line if available
- {
- //printf("feol out={%s}\n",QCString(data+pi).left(i-pi).data());
- out.addStr(data+pi,i-pi);
- }
// found end marker, skip over this block
//printf("feol.block out={%s}\n",QCString(data+i).left(end+l+1-i).data());
- out.addStr(data+i,end+l+1-i);
- pi=-1;
- i=end+l+1; // continue after block
- end=i+1;
+ end = end + l + 2;
break;
}
}
@@ -2110,16 +2106,8 @@ static void findEndOfLine(GrowBuf &out,const char *data,int size,
if (tolower(data[end])=='p' && tolower(data[end+1])=='r' &&
tolower(data[end+2])=='e' && data[end+3]=='>') // tag
{
- if (pi!=-1) // output previous line if available
- {
- out.addStr(data+pi,i-pi);
- }
- // output part until
- out.addStr(data+i,end-1-i);
- // output part until
- i = end-1 + processHtmlTag(out,data+end-1,end-1,size-end+1);
- pi=-1;
- end = i+1;
+ // skip part until including
+ end = end + processHtmlTagWrite(out,data+end-1,end-1,size-end+1,false) + 2;
break;
}
else
--
cgit v0.12