Since the mathematics is converted to MathML internally, it can't
include arbitrary HTML like this, since there is no mechanism for
including HTML for display within MathML. Since the mathematics could
be displayed as MathML (for those who have the MathML output jax
specified), everything that the TeX input jax produces must be able to
be rendered as MathML.
I was going to recommend that you use
\href{definitionSIM.html}{\text{definition SIM}}
instead, but your next message indicated why you didn't do that.
Because MathML has a means of including hypertext references (via the
href attribute on any MathML element), the \href macro can be
implemented in MathJax. But then "knowl" anchor is non-standard and
there is no corresponding mechanism in MathML, so MathJax will not be
able to produce it.
While it would be possible, I suppose, to have MathJax add a non-
standard "knowl" attribute to its internal MathML elements, but even
it these were copied to the output MathML or HTML-CSS elements, I
don't think that would work with your knowl.js implementation, for
several reasons. I don't use jQuery, so I'm not up on all its
details, but it looks like the knowl's are located and modified when
the page first becomes ready. Since MathJax doesn't typeset the
contents until after that, even if the knowls were inserted, they
would not get modified by the knowls script and so would not operate
properly. Second, the knowl code assumes that the anchor is within a
<div> or a <p> (and only does a special case for a table), but you are
asking that the anchor be part of some very complicated output
generated by MathJax. So even if the knowl was active, it would try
to insert its text into the middle of the equation, which would
probably cause havoc with the layout (both in HTML-CSS and NativeMML
output).
The upshot is, I don't think you are going to get this to work as you
would like. I still have more to do in terms of being able to add
customized interactivity to the mathematics, I'm afraid.
Davide
PS, I know you have asked me privately to look at the knowl approach,
and I haven't forgotten about that; I just haven't gotten to it yet.
And this doesn't address the problem that the knowl.js code currently
runs before MathJax produces its output, and so the code that attaches
the event handles for knowls will have already run by the time any
knowls produced by MathJax show up. So knowl.js would also need
modification, and synchronization with MathJax. There is also the
modifications needed to locate the correct place for the knowl to
appear so that it is not inside the mathematical equation itself,
which requires a knowledge of the results of MathJax's HTML-CSS output
jax. Those changes are certainly possible, but it is not a trivial
job, and there are a number of issues that have to be carefully handled.
Davide
That is a clever approach, and I would not have thought of using the
javascript URL (though it seems obvious now that you have done it).
Kudos.
> any hope of implementing \newcounter, \value, etc., in MathJax2?
> Would've made this a lot easier...
No, I do not expect to implement those control sequences. You are
actually working much harder than necessary here, because you are
thinking in TeX rather than Javascript. I have attached my own
version of an extension that implements your approach, but doesn't
require all the extra macros. It also puts it into the MathJax object
so that it doesn't pollute the global namespace, and doesn't rely on
the HTML.js extension being loaded (GetArgumentMML is part of that
extension, so your code relies on that; fortunately it gets loaded
automatically by \class and \cssID, but the timing of their use is
crucial to making your code work). My code also handles setting up
the styles automatically, and signaling that the knowl extension is
loaded.
Not all CSS styling can be effectively applied to MathJax output. In
particular, borders and padding need to be handled carefully.
Currently, they only work if they are applied explicitly via a style
attribute of the underlying MathML (and even that is not currently in
the v1.1 code, if I remember properly, so only works properly in
v2.0). My code uses this approach to do the underline dots. Note,
however, that this might not look all that great on some mathematics
(e.g., fractions, for example). The hover background change will have
problems with some math as well, as the HTML bounding boxes are not
the same as the TeX bounding boxes. For example, fractions will not
have their backgrounds cover the whole fraction (only a line-sized
part around the fraction line). There is no easy work around for this
at the moment.
Anyway, if you want to try out this file, you will need to put it
someplace where you can load it, and then change the loadComplete()
line at the bottom so that its URL is the one where the file is loaded
from, and then use "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML,url
" to load MathJax (where "url" is replaced by the URL of the location
of this file).
I have put a copy of Tom's sample file (but using my modifications) at
http://devel.mathjax.org/mathjax/dpvc/test/knowl/knowl.html
for you to try out. This uses the CDN version of MathJax (so the
underlining isn't performed). There is a copy at
http://devel.mathjax.org/mathjax/dpvc/test/knowl/knowl2.html
that uses the v2.0-candidate, so the underline is performed. That is
the only change in the file.
Davide
I think MathML element DO support it; only there is no mechanism in
the HTML-CSS output to attach them. So it is theoretically possible,
but not yet implemented.
>> You are
>> actually working much harder than necessary here, because you are
>> thinking in TeX rather than Javascript.
>
> Fair enough. My first attempt (the one that didn't have the unique-ID
> mechanism yet) was purely a TeX macro, just chaining together \href,
> \class, and \cssId. The \href used a javascript: URL to call the
> showKnowl() method, basically the same idea as what I used in my final
> version. I thought the business of getting the counter value out to
> the showKnowl() method was a kludge, but it worked.
Indeed, I didn't mean to be dismissive. Only to point out that there
was a simpler way to accomplish your goal than to implement a lot of
new control sequences.
>> I have attached my own version of an extension ...
>
> Yay! My "feasibility proof" had exactly the desired effect -- getting
> the discussion started again and getting a real solution.
Glad you got what you wanted. :-)
It was the javascript URL that sparked my interest again.
>> Not all CSS styling can be effectively applied to MathJax output.
> [...]
>> There is no easy work around for this
>> at the moment.
>
> I did the best I could, working with the CDN version.
This was not meant as criticism, but just information.
> I see what you are doing in the code to
> spruce up the styles. I wasn't aware you could do that sort of thing
> inside an extension -- it opens up a host of possibilities (says the
> man at the keyboard, grinning evilly).
There are some severe limitations to the number of stylesheets that IE
will allow (only 32 total) and currently MathJax does not try to
conserve these, so there is a real chance of overflowing the IE limit
if there are too many stylesheets added in this way. But it does
work well in most browsers. It is on my list of improvements to use
only one stylesheet and simply add rules to it rather than make new
ones each time (as is currently done). But there have been more
pressing matters.
>> I have put a copy of Tom's sample file (but using my modifications)
>> at
>
> Very nice output, and certainly an improvement on my work.
>
> I still don't think (as I said earlier in the thread) that this should
> be included in the main MathJax distro.
I agree with you, and don't plan to include it (since it relies on
jQuery and the knowl library, which are not part of MathJax). But it
is good that it can be loaded separately as an extension (or
configuration file).
> The other thing I think I
> have demonstrated here is the viability of third-party extensions.
Sure, there is no reason that you can't make your own and host your
own extensions. This is a nice example of that, as you say.
> Maybe I can put together a third-party extension implementing
> \newcounter,
> etc., now that I am more familiar with the innards of the API.
No reason why you can't. MathJax 2.0 includes some features that
allow localized macro definitions (in its new begingroup extension),
so you might want to tie into that if you are doing counters and such,
since it would be nice to be able to have localized counters.
> Are there any plans for some sort of repository of third-party
> extensions?
We have kicked around the idea, but haven't got anything in place. It
is one of those things that tends not to get done until there is
something to put into it. So perhaps yours can be the ones that get
that project moving. It is also something that could be taken on by
the user community rather than through MathJax directly. We have our
plate pretty full at the moment, and this is something that would be
of real benefit that someone in the community could foster.
Anyway, keep up the good work.
Davide
id = KNOWL.GetID();
to
var id = KNOWL.GetID();
Sorry about that.
Davide
Implementation in MathJax is one thing, but I checked some of the
relevant specs on this point when I started thinking about how to
proceed, and I'm not convinced that MathML elements would necessarily
support event attributes, even in an HTML5 context. The MathML spec
doesn't mention event attributes at all (as well it shouldn't, they
would be quite beside the point for that spec), so it comes down to
how MathML embeds in HTML5. The HTML5 spec says that all HTML5
elements should support all event attributes (except of course for the
attributes that are specific to particular elements, like onload), but
in the section about embedding MathML in HTML5, it scrupulously says
that MathML is outside the HTML5 namespace. This is open to some
interpretation, so different browsers may do different things here,
but I read this as saying in particular that the event attributes need
not be supported by the MathML elements. (David Carlisle may have a
different take on this, but this is how I read it.) For cross-browser
implementations, I usually figure that it is best to stick with
conservative interpretations of the specs, so I wouldn't want to rely
on being able to use onclick in a math element.
> > Are there any plans for some sort of repository of third-party
> > extensions?
>
> We have kicked around the idea, but haven't got anything in place.
[...]
> this is something that would be
> of real benefit that someone in the community could foster.
After I get a counters extension working, I'll slap a basic repository
together on my server and put the counters extension and this knowls
extension onto it as seeds, then post something to this group about
it. Don't expect me to use a fancy subversioning server, though.
What you say is certainly true, there is no guarantee that onclick
will be supported. I did a little checking, though, and found that
Firefox, Safari, and Opera all support onclick events (when they are
added dynamically to the MathML elements via JavaScript). Only
MathPlayer seems to be a hold out in this respect. MathPlayer does
allow onclick on the root <math> element, but not on individual
elements within the math. Unfortunately, it doesn't support any of
the mechanisms for canceling the event or preventing its default
action, so clicks always produce the MathPlayer zoom box, even when
there is an onclick handler that tries to cancel the event. (This is
one of the reasons I had to use an overlay to trap mouse events for
MathPlayer in MathJax.) This testing was in MathPlayer2.2. Not sure
what differences there might be with MathPlayer3.
>>> Are there any plans for some sort of repository of third-party
>>> extensions?
>>
>> We have kicked around the idea, but haven't got anything in place.
> [...]
>> this is something that would be
>> of real benefit that someone in the community could foster.
>
> After I get a counters extension working, I'll slap a basic repository
> together on my server and put the counters extension and this knowls
> extension onto it as seeds, then post something to this group about
> it. Don't expect me to use a fancy subversioning server, though.
I wasn't actually meaning that YOU needed to do it, though I
appreciate your volunteering.
Davide
--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.