#3311 closed enhancement (fixed)
Enable loading JS globally when inside the info annotation of package.mo
Reported by: | Dietmar Winkler | Owned by: | Adeel Asghar |
---|---|---|---|
Priority: | high | Milestone: | 1.9.4 |
Component: | OMEdit | Version: | trunk |
Keywords: | MathJax | Cc: |
Description
I have the use case that I like to use MathJax in the documentation of my models. Now this functionality was implemented as part of #1809 and the request for a global <script>...</script>
was part of #2490 but unfortunately overlooked.
What I think would be ideal is that if one has some <script>...</script>
inside the top-level package.mo
then that script would be loaded for the rendering of all documentation annotations of all the classes in that package.
That we I could define
annotation(Documentation(info="<html> <script type=\"text/javascript\" src=\"https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML\"> </script> </html>"));
once and be done with it.
Change History (16)
comment:1 by , 10 years ago
Keywords: | MathJax added |
---|
comment:2 by , 10 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:3 by , 10 years ago
Both solutions would be fine, though the annotation would allow to store the setting with the library rather than the local OMEdit instance. So I would probably prefer that.
comment:4 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Done in 8eeaa19/OMEdit.
Now you can create models like this,
package P model M annotation(Documentation(info="<html> <a href=\"javascript:HelloWorld()\">Click here</a> </HTML>")); end M; annotation(Documentation(__OpenModelica_infoHeader="<script type=\"text/javascript\"> function HelloWorld() { alert(\"Hello World!\"); } </script>")); end P;
Anything defined in __OpenModelica_infoHeader
will be added in the <head>
section of the nested class html documentation.
comment:5 by , 9 years ago
Milestone: | Future → 1.9.4 |
---|
comment:7 by , 9 years ago
Where would one best document this feature? Any suggestions into which section to add this?
comment:8 by , 9 years ago
follow-up: 11 comment:9 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Unfortunately the now the functionality of #2490 is broken. Taking your example:
hello.js
:function HelloWorld() { alert(\"Hello World!\");
P.mo
:package P model M annotation(Documentation(info="<html> <a href=\"javascript:HelloWorld()\">Click here</a> </html>")); end M; annotation(Documentation(__OpenModelica_infoHeader=" <script type=\"text/javascript\" src=\"modelica://P/hello.js\"> </script>")); end P;
Now the rendering of the documentation is completely broken. Inlining the script location directly does not help either. It's very important to keep the "load from local resource" functionality for proper independent library packaging.
comment:10 by , 9 years ago
There are actually more problems with the implementation. Even when not relying on load from local resource (#2499) then here is an example that works:
package P_FB model FallbackTest annotation(Documentation(info="<html> <script type=\"text/javascript\" src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML\"> </script> $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ </html>")); end FallbackTest; annotation(Documentation(__OpenModelica_infoHeader="")); end P_FB;
and one that does not work:
package P_FB model FallbackTest annotation(Documentation(info="<html> $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ </html>")); end FallbackTest; annotation(Documentation(__OpenModelica_infoHeader=" <script type=\"text/javascript\" src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML\"> </script>")); end P_FB;
with the error message:
[46] 13:23:29 Scripting Notification QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once.
comment:11 by , 9 years ago
Replying to dietmarw:
Unfortunately the now the functionality of #2490 is broken. Taking your example:
hello.js
:function HelloWorld() { alert(\"Hello World!\");
There are problems with hello.js
. The function's closing bracket is missing and there is no need to escaspe quotes here.
P.mo
:package P model M annotation(Documentation(info="<html> <a href=\"javascript:HelloWorld()\">Click here</a> </html>")); end M; annotation(Documentation(__OpenModelica_infoHeader=" <script type=\"text/javascript\" src=\"modelica://P/hello.js\"> </script>")); end P;Now the rendering of the documentation is completely broken. Inlining the script location directly does not help either. It's very important to keep the "load from local resource" functionality for proper independent library packaging.
comment:12 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Fixed in c6988d4/OMEdit.
All the above three examples are working now.
comment:13 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Sorry but loading from file still does not work :-( (I corrected my hello.js
file).
I tried boths structures:
P ├── hello.js └── package.mo
and
. ├── hello.js └── P.mo
BTW shouldn't there be a function in OMEdit that one can save a single file lib into folder structure?
comment:14 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
My bad. Seems I was still running an older version. Fix confirmed.
Or possibly some other way, like
Documentation(__OpenModelica_infoHeader=...)
. Or just allowing OMEdit to specify it globally in a config setting.