MathJax with Trac

31 views
Skip to first unread message

Jan Schmidt

unread,
Sep 2, 2011, 4:17:02 AM9/2/11
to MathJax Users
Hi,

since the revision 1.1 no default configuration ist used anymore.
This is a problem for trac, because the url gets encodet (? to %3F and
= to %3D).

This results in en Error 403 Forbidden from MatJax.js

Please, can you tell me how to fix it?

Davide P. Cervone

unread,
Sep 3, 2011, 3:35:04 PM9/3/11
to mathja...@googlegroups.com
This seems to be a Trac issue (or at least a TracMathJaxPlugin issue),
not a MathJax one itself. You might want to ping the author at

http://trac-hacks.org/ticket/8758

which is the ticket for this issue in the plugin. I suspect that
there is something that the plugin can do differently to allow the
parameters for the script call.

Otherwise, if you can add a script call like

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
config: ["TeX-AMS_HTML.js"],
jax: ["input/TeX"]
});
</script>

then you could load the configuration file that way.

Davide

Jan Schmidt

unread,
Sep 5, 2011, 2:00:09 AM9/5/11
to MathJax Users


On 3 Sep., 21:35, "Davide P. Cervone" <d...@union.edu> wrote:
> This seems to be a Trac issue (or at least a TracMathJaxPlugin issue),  
> not a MathJax one itself.  You might want to ping the author at
>
>        http://trac-hacks.org/ticket/8758

I know this already.

The problem is, that I cannot force trac to put any other script than
type text/javascript
into the html-header. Nor is it possible to write script-code directly
into the header. I have
to put the code into an extra file und load this like mathjax.js with

<script type="text/javascript" source="config.js"> </script>

The only part I can change from within a Trac-plugin is the part after
source=

I played a long time with that and till now its not working. The only
way is to give the
config-file in the way like ?config=default.

But Trac encodes the url and that does MatJax not like.

I'm not an javascript-freak and the code of mathjax.js is not really
readable and so I cannot write
a fix for that. But I think, the parse-arguments-function has only a
little bit to modified.

Davide P. Cervone

unread,
Sep 6, 2011, 7:24:41 AM9/6/11
to mathja...@googlegroups.com
> The problem is, that I cannot force trac to put any other script than
> type text/javascript
> into the html-header. Nor is it possible to write script-code directly
> into the header.

I suspect that this isn't exactly true. For example, since you can
load an external script, you could create a small script that inserts
the desired SCRIPT tags into the header and load that. This would
"bootstrap" MathJax into the page. It's not pretty, but would
certainly work, if you have access to a place where you serve static
content on a server.

I would guess that there are other ways, too, but I don't know Trac
and can't tell you what they are. The routine that is used to add the
script might have optional parameters to handle the things like ?
config=, though I don't know for sure. Also, it might be possible to
modify the output WITHOUT going through the API directly (by modifying
the structures that you are passed). I have not looked into this at
all, but if Trac can add to the page, you probably can by hand as
well. Not that I'm recommending it.

In any case, this seems to be a Trac issue, not a MathJax one. I
would file a bug report with the Trac developers asking for more
control over the script tags.

> I have
> to put the code into an extra file und load this like mathjax.js with
>
> <script type="text/javascript" source="config.js"> </script>

if you do this INSTEAD of loading MathJax.js, you could have config.js
insert the script that loads MathJax and set the src attribute WITHOUT
it being encoded. That would solve your problem.

> I'm not an javascript-freak and the code of mathjax.js is not really
> readable and so I cannot write
> a fix for that. But I think, the parse-arguments-function has only a
> little bit to modified.

No, this will not work because MathJax does not actually run in this
case. If the URL is encodes to be

http://cdn.mathjax.org/mathjax/latest/MathJax.js%3Fconfig%3DTeX-AMS_HTML

then the file that the server is being asked to look for and serve is
"MathJax.js?config=TeX-AMS_HTML" not "MathJax.js" with a config
parameter. (That is, the "?config=..." is part of the file name).
Since a file with this name doesn't exist, you will not get MathJax.js
but a "file not found" error, and MathJax doesn't run. So MathJax
can't be used to fix this problem. It has to be fixed at the Trac end.

Davide

Reply all
Reply to author
Forward
0 new messages