Skip to content

Commit eb31a2e

Browse files
committed
Handle <html> in class comments
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18710 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent a99b042 commit eb31a2e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Examples/GenerateDoc.mos

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,13 @@ end itemFile;
173173

174174
function toHtml
175175
input String str;
176-
output String ostr := OpenModelica.Scripting.stringReplace(OpenModelica.Scripting.stringReplace(OpenModelica.Scripting.stringReplace(str,\"&\",\"&amp;\"),\"<\",\"&lt;\"),\">\",\"&gt;\");
176+
output String ostr;
177+
protected
178+
Integer n;
179+
String[2] matches;
180+
algorithm
181+
(n,matches) := OpenModelica.Scripting.regex(str,\"^[:space:]*<html>(.*)</html>[:space:]*\",caseInsensitive=true,maxMatches=2);
182+
ostr := if n==2 then matches[2] else OpenModelica.Scripting.stringReplace(OpenModelica.Scripting.stringReplace(OpenModelica.Scripting.stringReplace(str,\"&\",\"&amp;\"),\"<\",\"&lt;\"),\">\",\"&gt;\");
177183
end toHtml;
178184

179185
record Item
@@ -234,7 +240,7 @@ for cl in classNames loop
234240
dirpaths := strtok(dirname(file),"/");
235241
dirs := dirs + " \"" + dirpaths[end] + "\" ";
236242
end if;
237-
comment := OpenModelica.Scripting.stringReplace(getClassComment(cl),"&","&amp;"); // let's escape "&" on the fly
243+
comment := toHtml(getClassComment(cl)); // let's escape "&" on the fly
238244
fileName := filename(contentStr);
239245
writeFile(filetmp, "<tr><td>" + svgIcon("Icons/" + fileName + ".svg",fileName + ".html","svgiconsmall",readSymlinks=readSymlinks) + "<a href=\"" + fileName + ".html\">" + contentStr + "</a></td><td>" + comment + "</td><td>" + modelVersion + "</td></tr>", append = true);
240246
end if;
@@ -250,7 +256,7 @@ if genBuiltin then
250256
if base == "ModelicaBuiltin.mo" or base == "MetaModelicaBuiltin.mo" then
251257
contentStr := typeNameString(cl);
252258
modelVersion := getVersion(cl);
253-
comment := OpenModelica.Scripting.stringReplace(getClassComment(cl),"&","&amp;"); // lets escape "&" on the fly
259+
comment := toHtml(getClassComment(cl)); // lets escape "&" on the fly
254260
fileName := filename(contentStr);
255261
writeFile(filetmp, "<tr><td><a href=\"" + fileName + ".html\">" + contentStr + "</a></td><td>" + comment + "</td><td>" + modelVersion + "</td></tr>", append = true);
256262
end if;

0 commit comments

Comments
 (0)