Jason Grout wrote:
> Minh Nguyen wrote:
>> On Sun, Jul 12, 2009 at 2:37 AM, Pat LeSmithe<qed...@gmail.com> wrote:
>>
>> <SNIP>
>>
>>> Apparently, the jsMath library hides all display equations, even if they
>>> are images.
>> I find this funny: I can view the rendered equations. It's just that I
>> have to refresh my browser every second. Even at that rate, the
>> equation would only be displayed for a fraction of a second :-)
> 
> 
> Davide,
> 
> You can see this happening at 
> http://sagemath.org/doc/reference/sage/numerical/knapsack.html (search 
> for the text "must satisfy the property")
> 


Davide sent me this extremely helpful reply.  Does anyone want to take 
this up as a small, but very helpful project?

Jason:

Here's what's going on:  jsMath looks for DIV's and SPAN's that are 
marked by CLASS="math" and treats their contents as TeX source code to 
process.  It replaces the original contents of the DIV or SPAN with the 
typeset version of the TeX code.  Because the image's are not DIV's or 
SPAN's jsMath ignores them (even though they are CLASS="math"), but the 
<DIV CLASS="math"> that contains an image is processed by jsMath.  It 
takes the text content of the DIV (empty in this case) and typesets it 
(the result is blank).  Thus the image disappears and is replaced by 
nothing.

There are a couple of possible solutions:  1) have the python program 
produce a class other than "math" for its output; 2) have jsMath look 
for something other than class="math" for its trigger; 3) use a 
preprocessor (in javascript) to modify the class of the DIV's that 
python produces so jsMath won't modify them.  It would need to run 
before jsMath.js.

I suspect 3 is the best solution.  You mention that you would like 
jsMath to process the ALT text of the images and replace them by the 
typeset output.  That function could also be folded into the 
preprocessor in (3) by searching for the images and changing them to 
SPAN's containing the TeX.  This would show up on screen as a change of 
all the images then the loading of jsMath, which would be visually 
apparent.  You might replace

     <IMG CLASS="math" ... ALT="tex-code">

by

     <SPAN CLASS="math"><IMG ...><SPAN 
STYLE="display:none">tex-code</SPAN></SPAN>

and

     <DIV CLASS="math">
     <p><IMG ... ALT="tex-code">
     </DIV>

by

     <DIV CLASS="math">
     <p><IMG ...>
     <SPAN STYLE="display:none">tex-code</SPAN>
     </DIV>

This would not alter the visual display until jsMath actually processes 
the SPAN.  It should not be that hard to write such a preprocessor.  You 
would load it before loading jsMath (via easy/load.js).

Davide




> Currently, an <img class="math" ...> displays the image, but an image 
> inside of a <div class="math"> is deleted.
> 
> The relevant HTML is:
> 
> <p>Let <img class="math" 
> src="../../_images/math/423e6d866fb7dea1490a6d84e9bd08e524a8ae74.png" 
> alt="L = (a_1, a_2, a_3, \dots, a_n)" /> be a non-empty sequence of
> non-negative integers. Then <img class="math" 
> src="../../_images/math/859ccf4cd60c7bc6b8fa1afc9a42dc811a826d6f.png" 
> alt="L" /> is said to be super-increasing if
> each <img class="math" 
> src="../../_images/math/412787c048e28774dc63fc27db42dc52ca858de7.png" 
> alt="a_i" /> is strictly greater than the sum of all previous values.
> That is, for each <img class="math" 
> src="../../_images/math/5104cf5e4b0a4dac3d89d924244871821acf1d22.png" 
> alt="a_i \in L" /> the sequence <img class="math" 
> src="../../_images/math/859ccf4cd60c7bc6b8fa1afc9a42dc811a826d6f.png" 
> alt="L" /> must satisfy the property</p>
> 
> <div class="math">
> <p><img 
> src="../../_images/math/db83da90af912a511752f6af9626076764786f3b.png" 
> alt="a_i &gt; \sum_{k=1}^{i-1} a_k" />
> </div></p>
> 
> <p>in order to be called a super-increasing sequence, where <img 
> class="math" 
> src="../../_images/math/71b363cfed7a38259d24cb0ac71c239743efffe5.png" 
> alt="|L| \geq 2" />.
> If <img class="math" 
> src="../../_images/math/859ccf4cd60c7bc6b8fa1afc9a42dc811a826d6f.png" 
> alt="L" /> has only one element, it is also defined to be a
> super-increasing sequence.</p>
> 
> (I just noticed that the </div> and </p> tags are in the wrong order for 
> the <div class="math">; maybe that is part of the problem?)
> 
> 
> Apparently, this is representative of what is now the standard python 
> documentation program output (so this is probably a wider concern than 
> just the Sage project).  Is there an easy way to make jsmath look at the 
> alt text of images as the latex source that should be there?  Ideally, 
> there would be a switch somewhere, maybe on the jsmath control panel, 
> that would tell jsmath to either leave the images alone, or to extract 
> and format the alt text and hide the image.
> 
> Thanks,
> 
> Jason
> 
> 
> > 
> 


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to