Skip to content

Commit b3915db

Browse files
committed
Incorrect interactive svg file for dot
When using a `\dot` command and having `svg` as format and `INTERACTIVE_SVG` set, the svg file generated by doxygen is incorrect. The message we get is like: ``` XML Parsing Error: mismatched tag. Expected: </svg>. Location: file:///.../html/dot_inline_dotgraph_1.svg Line Number 332, Column 3: ```` and xmllint gives: ``` html\dot_inline_dotgraph_1.svg:332: parser error : Opening and ending tag mismatch: svg line 53 and g </g> ^ html\dot_inline_dotgraph_1.svg:334: parser error : Extra content at the end of the document <g id="navigator" transform="translate(0 0)" fill="#404254"> ^ ``` Doxygen relies on a `<title>` tag inside the originally generated svg file, but in the newer versions of dot this is not present anymore (still present in 2.38 but absent already in 2.50). The problem can be solved by explicitly defining a 'title' with the digraph in the dot setup.
1 parent 73e5fc2 commit b3915db

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

src/docnode.cpp

+50-1
Original file line numberDiff line numberDiff line change
@@ -4011,7 +4011,56 @@ int DocPara::handleCommand(DocNodeVariant *thisVariant,const QCString &cmdName,
40114011
parser()->defaultHandleTitleAndSize(CMD_DOT,vDocVerbatim,dv->children(),width,height);
40124012
parser()->tokenizer.setStateDot();
40134013
retval = parser()->tokenizer.lex();
4014-
dv->setText(parser()->context.token->verb);
4014+
// with interactive SVG it is important that a digraph has a title
4015+
// as otherwise an invalid svg file will be created by doxygen.
4016+
if ((Config_getEnum(DOT_IMAGE_FORMAT) == DOT_IMAGE_FORMAT_t::svg) && Config_getBool(INTERACTIVE_SVG))
4017+
{
4018+
QCString orgVerb = parser()->context.token->verb + "\n"; // so we now for sure we have a "\n" at the end
4019+
QCString newVerb;
4020+
int start = 0;
4021+
int end = 0;
4022+
int size = orgVerb.size();
4023+
while (end<size)
4024+
{
4025+
while (end<size && orgVerb[end] != '\n') end++;
4026+
QCString newStr = orgVerb.mid(start,end-start);
4027+
QCString newStrStripped = newStr.stripWhiteSpace();
4028+
if (newStrStripped.startsWith("digraph"))
4029+
{
4030+
if (newStrStripped.length() == 7)
4031+
{
4032+
// no label
4033+
newVerb += "digraph \"inline_dotgraph\"\n";
4034+
}
4035+
else if (newStrStripped.mid(7).stripWhiteSpace().at(0) == '{')
4036+
{
4037+
// no label direct {
4038+
newVerb += "digraph \"inline_dotgraph\" ";
4039+
newVerb += newStrStripped.mid(7);
4040+
newVerb += "\n";
4041+
}
4042+
else
4043+
{
4044+
newVerb += newStr + "\n";
4045+
}
4046+
end++;
4047+
start = end;
4048+
newVerb += orgVerb.mid(start);
4049+
break;
4050+
}
4051+
else
4052+
{
4053+
newVerb += newStr + "\n";
4054+
}
4055+
end++;
4056+
start = end;
4057+
}
4058+
dv->setText(newVerb);
4059+
}
4060+
else
4061+
{
4062+
dv->setText(parser()->context.token->verb);
4063+
}
40154064
dv->setWidth(width);
40164065
dv->setHeight(height);
40174066
dv->setLocation(parser()->context.fileName,parser()->tokenizer.getLineNr());

0 commit comments

Comments
 (0)