Skip to content

Commit 3670a15

Browse files
authored
Merge pull request doxygen#6784 from albert-github/feature/issue_6781_2
issue doxygen#6781 Unable to use math in markdown table headers
2 parents 73dd780 + bf1e768 commit 3670a15

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

doc/translator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,9 +1821,9 @@ def generateLanguageDoc(self):
18211821
tplDic['numLangStr'] = str(self.numLang)
18221822

18231823
# Define templates for HTML table parts of the documentation.
1824-
htmlTableTpl = '''\
1824+
htmlTableTpl = '''
18251825
\\htmlonly
1826-
</p>
1826+
</p>
18271827
<table align="center" cellspacing="0" cellpadding="0" border="0">
18281828
<tr bgcolor="#000000">
18291829
<td>
@@ -1842,7 +1842,7 @@ def generateLanguageDoc(self):
18421842
</td>
18431843
</tr>
18441844
</table>
1845-
<p>
1845+
<p>
18461846
\\endhtmlonly
18471847
'''
18481848
htmlTableTpl = textwrap.dedent(htmlTableTpl)

src/markdown.cpp

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ static int processQuoted(GrowBuf &out,const char *data,int,int size)
524524
/** Process a HTML tag. Note that <pre>..</pre> are treated specially, in
525525
* the sense that all code inside is written unprocessed
526526
*/
527-
static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
527+
static int processHtmlTagWrite(GrowBuf &out,const char *data,int offset,int size,bool doWrite)
528528
{
529529
if (offset>0 && data[-1]=='\\') return 0; // escaped <
530530

@@ -547,7 +547,7 @@ static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
547547
tolower(data[i+2])=='p' && tolower(data[i+3])=='r' &&
548548
tolower(data[i+4])=='e' && tolower(data[i+5])=='>')
549549
{ // found </pre> tag, copy from start to end of tag
550-
out.addStr(data,i+6);
550+
if (doWrite) out.addStr(data,i+6);
551551
//printf("found <pre>..</pre> [%d..%d]\n",0,i+6);
552552
return i+6;
553553
}
@@ -570,13 +570,13 @@ static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
570570
if (data[i]=='/' && i<size-1 && data[i+1]=='>') // <bla/>
571571
{
572572
//printf("Found htmlTag={%s}\n",QCString(data).left(i+2).data());
573-
out.addStr(data,i+2);
573+
if (doWrite) out.addStr(data,i+2);
574574
return i+2;
575575
}
576576
else if (data[i]=='>') // <bla>
577577
{
578578
//printf("Found htmlTag={%s}\n",QCString(data).left(i+1).data());
579-
out.addStr(data,i+1);
579+
if (doWrite) out.addStr(data,i+1);
580580
return i+1;
581581
}
582582
else if (data[i]==' ') // <bla attr=...
@@ -596,7 +596,7 @@ static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
596596
else if (!insideAttr && data[i]=='>') // found end of tag
597597
{
598598
//printf("Found htmlTag={%s}\n",QCString(data).left(i+1).data());
599-
out.addStr(data,i+1);
599+
if (doWrite) out.addStr(data,i+1);
600600
return i+1;
601601
}
602602
i++;
@@ -607,6 +607,10 @@ static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
607607
//printf("Not a valid html tag\n");
608608
return 0;
609609
}
610+
static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
611+
{
612+
return processHtmlTagWrite(out,data,offset,size,true);
613+
}
610614

611615
static int processEmphasis(GrowBuf &out,const char *data,int offset,int size)
612616
{
@@ -2093,17 +2097,9 @@ static void findEndOfLine(GrowBuf &out,const char *data,int size,
20932097
{
20942098
if (qstrncmp(&data[end+1],endBlockName,l)==0)
20952099
{
2096-
if (pi!=-1) // output previous line if available
2097-
{
2098-
//printf("feol out={%s}\n",QCString(data+pi).left(i-pi).data());
2099-
out.addStr(data+pi,i-pi);
2100-
}
21012100
// found end marker, skip over this block
21022101
//printf("feol.block out={%s}\n",QCString(data+i).left(end+l+1-i).data());
2103-
out.addStr(data+i,end+l+1-i);
2104-
pi=-1;
2105-
i=end+l+1; // continue after block
2106-
end=i+1;
2102+
end = end + l + 2;
21072103
break;
21082104
}
21092105
}
@@ -2117,16 +2113,8 @@ static void findEndOfLine(GrowBuf &out,const char *data,int size,
21172113
if (tolower(data[end])=='p' && tolower(data[end+1])=='r' &&
21182114
tolower(data[end+2])=='e' && data[end+3]=='>') // <pre> tag
21192115
{
2120-
if (pi!=-1) // output previous line if available
2121-
{
2122-
out.addStr(data+pi,i-pi);
2123-
}
2124-
// output part until <pre>
2125-
out.addStr(data+i,end-1-i);
2126-
// output part until </pre>
2127-
i = end-1 + processHtmlTag(out,data+end-1,end-1,size-end+1);
2128-
pi=-1;
2129-
end = i+1;
2116+
// skip part until including </pre>
2117+
end = end + processHtmlTagWrite(out,data+end-1,end-1,size-end+1,false) + 2;
21302118
break;
21312119
}
21322120
else

0 commit comments

Comments
 (0)