Skip to content

Commit 7f5f364

Browse files
committed
issue #6473 Plantuml parse error
For "verbatim" type commands the initial indentation counting as done in `detab()` during the markdown phase should be disabled. For the ease of the implementation (not to repeat logics about these, nested, "verbatim" commands the new internal command `\iskip` has bveen andded together with its counterpart `\endiskip`.
1 parent a6988ea commit 7f5f364

File tree

3 files changed

+76
-9
lines changed

3 files changed

+76
-9
lines changed

doc_internal/commands_internal.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and the version in which they were introduced.
77
\refitem cmdialias \\ialias
88
\refitem cmdendicode \\endicode
99
\refitem cmdendiliteral \\endiliteral
10+
\refitem cmdendiskip \\endiskip
1011
\refitem cmdendiverbatim \\endiverbatim
1112
\refitem cmdianchor \\ianchor
1213
\refitem cmdicode \\icode
@@ -16,6 +17,7 @@ and the version in which they were introduced.
1617
\refitem cmdiliteral \\iliteral
1718
\refitem cmdiprefix \\iprefix
1819
\refitem cmdiraise \\iraise
20+
\refitem cmdiskip \\iskip
1921
\refitem cmdiverbatim \\iverbatim
2022
\endsecreflist
2123

@@ -140,6 +142,15 @@ and the version in which they were introduced.
140142

141143
\since doxygen version 1.11.0
142144

145+
<hr>
146+
\section cmdiskip \\iskip
147+
\addindex \\iskip
148+
149+
Internal doxygen command to top determing the inital white space as calculated by the detab() function.
150+
Inserted when processing commands that contain literal text like `\startuml`, `\verbatim`, `<code>` etc.
151+
152+
\since doxygen version 1.12.0
153+
143154
<hr>
144155
\section cmdiprefix \\iprefix "<label>"
145156
\addindex \\iprefix
@@ -151,6 +162,14 @@ and the version in which they were introduced.
151162

152163
\since doxygen version 1.11.0
153164

165+
<hr>
166+
\section cmdendiskip \\endiskip
167+
168+
\addindex \\endiskip
169+
Ends a block of text that was started with a \ref cmdiskip "\\iskip" command.
170+
171+
\since doxygen version 1.12.0
172+
154173
<hr>
155174
\section cmdendiverbatim \\endiverbatim
156175

src/scanner.l

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6973,7 +6973,8 @@ NONLopt [^\n]*
69736973
<DocBlock>({CMD}{CMD}){ID}/[^a-z_A-Z0-9] { // escaped command
69746974
yyextra->docBlock << yytext;
69756975
}
6976-
<DocBlock>{CMD}("f$"|"f["|"f{"|"f(") {
6976+
<DocBlock>{CMD}("f$"|"f["|"f{"|"f(") {
6977+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\iskip";
69776978
yyextra->docBlock << yytext;
69786979
yyextra->docBlockName=&yytext[1];
69796980
if (yyextra->docBlockName.at(1)=='[')
@@ -7017,20 +7018,23 @@ NONLopt [^\n]*
70177018
yyextra->docBlock << yytext;
70187019
}
70197020
<DocBlock>{B}*"<"{PRE}">" {
7021+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\iskip";
70207022
yyextra->docBlock << yytext;
70217023
yyextra->docBlockName="<pre>";
70227024
yyextra->fencedSize=0;
70237025
yyextra->nestedComment=0;
70247026
BEGIN(DocCopyBlock);
70257027
}
70267028
<DocBlock>{CMD}"startuml"/[^a-z_A-Z0-9\-] { // verbatim command (which could contain nested comments!)
7029+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\iskip";
70277030
yyextra->docBlock << yytext;
70287031
yyextra->docBlockName="uml";
70297032
yyextra->fencedSize=0;
70307033
yyextra->nestedComment=0;
70317034
BEGIN(DocCopyBlock);
70327035
}
70337036
<DocBlock>{CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"manonly"|"rtfonly"|"docbookonly"|"dot"|"msc"|"code")/[^a-z_A-Z0-9\-] { // verbatim command (which could contain nested comments!)
7037+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\iskip";
70347038
yyextra->docBlock << yytext;
70357039
yyextra->docBlockName=&yytext[1];
70367040
yyextra->fencedSize=0;
@@ -7040,6 +7044,7 @@ NONLopt [^\n]*
70407044
<DocBlock>"\\ilinebr "({B}*"*"+)?{B}{0,3}"~~~"[~]* {
70417045
QCString pat = substitute(yytext+9,"*"," "); // skip over "\ilinebr " part
70427046
yyextra->docBlock << "\\ilinebr ";
7047+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\iskip";
70437048
yyextra->docBlock << pat;
70447049
yyextra->docBlockName="~~~";
70457050
yyextra->fencedSize=pat.stripWhiteSpace().length();
@@ -7048,6 +7053,7 @@ NONLopt [^\n]*
70487053
}
70497054
<DocBlock>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
70507055
QCString pat = substitute(yytext,"*"," ");
7056+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\iskip";
70517057
yyextra->docBlock << pat;
70527058
yyextra->docBlockName="~~~";
70537059
yyextra->fencedSize=pat.stripWhiteSpace().length();
@@ -7059,6 +7065,7 @@ NONLopt [^\n]*
70597065
<DocBlock>"\\ilinebr "({B}*"*"+)?{B}{0,3}"```"[`]* {
70607066
QCString pat = substitute(yytext+9,"*"," "); // skip over "\ilinebr " part
70617067
yyextra->docBlock << "\\ilinebr ";
7068+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\iskip";
70627069
yyextra->docBlock << pat;
70637070
yyextra->docBlockName="```";
70647071
yyextra->fencedSize=pat.stripWhiteSpace().length();
@@ -7069,7 +7076,8 @@ NONLopt [^\n]*
70697076
<DocBlock>^({B}*"*"+)?{B}{0,3}"```"[`]*/"{"[^}]+"}" |
70707077
<DocBlock>^({B}*"*"+)?{B}{0,3}"```"[`]* {
70717078
QCString pat = substitute(yytext,"*"," ");
7072-
yyextra->docBlock << pat;
7079+
yyextra->docBlock << "\\iskip";
7080+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\iskip";
70737081
yyextra->docBlockName="```";
70747082
yyextra->fencedSize=pat.stripWhiteSpace().length();
70757083
yyextra->nestedComment=0;
@@ -7078,6 +7086,7 @@ NONLopt [^\n]*
70787086
<DocBlock>{B}*"<"{CODE}">" {
70797087
if (yyextra->insideCS)
70807088
{
7089+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\iskip";
70817090
yyextra->docBlock << yytext;
70827091
yyextra->docBlockName="<code>";
70837092
yyextra->nestedComment=0;
@@ -7102,36 +7111,40 @@ NONLopt [^\n]*
71027111
/* ---- Copy verbatim sections ------ */
71037112

71047113
<DocCopyBlock>"</"{PRE}">" { // end of a <pre> block
7105-
yyextra->docBlock << yytext;
71067114
if (yyextra->docBlockName=="<pre>")
71077115
{
7116+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\endiskip";
71087117
yyextra->docBlockName="";
71097118
BEGIN(DocBlock);
71107119
}
7120+
yyextra->docBlock << yytext;
71117121
}
71127122
<DocCopyBlock>"</"{CODE}">" { // end of a <code> block
7113-
yyextra->docBlock << yytext;
71147123
if (yyextra->docBlockName=="<code>")
71157124
{
7125+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\endiskip";
71167126
yyextra->docBlockName="";
71177127
BEGIN(DocBlock);
71187128
}
7129+
yyextra->docBlock << yytext;
71197130
}
71207131
<DocCopyBlock>[\\@]("f$"|"f]"|"f}"|"f)") {
7121-
yyextra->docBlock << yytext;
71227132
if (yyextra->docBlockName==&yytext[1])
71237133
{
7134+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\endiskip";
71247135
yyextra->docBlockName="";
71257136
BEGIN(DocBlock);
71267137
}
7138+
yyextra->docBlock << yytext;
71277139
}
71287140
<DocCopyBlock>[\\@]("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"endrtfonly"|"enddot"|"endmsc"|"enduml"|"endcode")/[^a-z_A-Z0-9] { // end of verbatim block
7129-
yyextra->docBlock << yytext;
71307141
if (&yytext[4]==yyextra->docBlockName)
71317142
{
7143+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\endiskip";
71327144
yyextra->docBlockName="";
71337145
BEGIN(DocBlock);
71347146
}
7147+
yyextra->docBlock << yytext;
71357148
}
71367149
<DocCopyBlock>^{B}*"*"+/{BN}+ { // start of a comment line
71377150
if ((yyextra->docBlockName=="verbatim") || (yyextra->docBlockName=="code") || (yyextra->docBlockName=="iliteral"))
@@ -7191,19 +7204,23 @@ NONLopt [^\n]*
71917204
}
71927205
<DocCopyBlock>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
71937206
QCString pat = substitute(yytext,"*"," ");
7194-
yyextra->docBlock << pat;
71957207
if (yyextra->docBlockName == "~~~" && yyextra->fencedSize==pat.stripWhiteSpace().length())
71967208
{
7209+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\endiskip";
7210+
yyextra->docBlockName="";
71977211
BEGIN(DocBlock);
71987212
}
7213+
yyextra->docBlock << pat;
71997214
}
72007215
<DocCopyBlock>^({B}*"*"+)?{B}{0,3}"```"[`]* {
72017216
QCString pat = substitute(yytext,"*"," ");
7202-
yyextra->docBlock << pat;
72037217
if (yyextra->docBlockName == "```" && yyextra->fencedSize==pat.stripWhiteSpace().length())
72047218
{
7219+
if (Config_getBool(MARKDOWN_SUPPORT)) yyextra->docBlock << "\\endiskip";
7220+
yyextra->docBlockName="";
72057221
BEGIN(DocBlock);
72067222
}
7223+
yyextra->docBlock << pat;
72077224
}
72087225
<DocCopyBlock>[^\<@/\*\]~"\$\\\n]+ { // any character that is not special
72097226
yyextra->docBlock << yytext;

src/util.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6984,6 +6984,7 @@ QCString detab(const QCString &s,size_t &refIndent)
69846984
constexpr auto doxy_nbsp = "&_doxy_nbsp;"; // doxygen escape command for UTF-8 nbsp
69856985
const int maxIndent=1000000; // value representing infinity
69866986
int minIndent=maxIndent;
6987+
bool skip = false;
69876988
while (i<size)
69886989
{
69896990
char c = data[i++];
@@ -6997,6 +6998,36 @@ QCString detab(const QCString &s,size_t &refIndent)
69976998
while (stop--) out.addChar(' ');
69986999
}
69997000
break;
7001+
case '@':
7002+
case '\\':
7003+
if (data[i] == '\\' || data[i] == '@') // escaped command
7004+
{
7005+
out.addChar(c);
7006+
col++;
7007+
c = data[i++];
7008+
out.addChar(c);
7009+
col++;
7010+
}
7011+
else if (i+5< size && data[i] == 'i' && data[i+1] == 's' && data[i+2] == 'k' && data[i+3] == 'i' && data[i+4] == 'p') // iskip command
7012+
{
7013+
i+=5;
7014+
c = data[i];
7015+
skip = true;
7016+
if (col+1<minIndent) minIndent=col+1;
7017+
}
7018+
else if (i+8 < size && data[i] == 'e' && data[i+1] == 'n' && data[i+2] == 'd' && data[i+3] == 'i' &&
7019+
data[i+4] == 's' && data[i+5] == 'k' && data[i+6] == 'i' && data[i+7] == 'p') // endiskip command
7020+
{
7021+
i+=8;
7022+
c = data[i];
7023+
skip = false;
7024+
}
7025+
else
7026+
{
7027+
out.addChar(c);
7028+
col++;
7029+
}
7030+
break;
70007031
case '\n': // reset column counter
70017032
out.addChar(c);
70027033
col=0;
@@ -7030,7 +7061,7 @@ QCString detab(const QCString &s,size_t &refIndent)
70307061
{
70317062
out.addChar(c);
70327063
}
7033-
if (col<minIndent) minIndent=col;
7064+
if (!skip && col<minIndent) minIndent=col;
70347065
col++;
70357066
}
70367067
}

0 commit comments

Comments
 (0)