jsMath for drupal?

2007-07-08
2013-04-29
  • Gustav W Delius

    Gustav W Delius - 2007-07-08

    Has anyone already implemented a jsMath filter for drupal (drupal.org)?

     
    • Davide P. Cervone

      Gustav:

      Nice to hear from you again.  I am not aware of a drupal module for jsMath.  Now that jsMath has the jsMath/easy/load.js configuration file, it should be pretty easy to create one.  You merely need to be able to load that file and the rest should be taken care of by jsMath.

      Davide

       
      • Gustav W Delius

        Gustav W Delius - 2007-07-09

        Yes, I agree that it will be very easy to do. I will try to find time one of these evenings to do it and contribute it to the drupal community. I think that developing a jsMath plugin is worthwhile to do for every popular platform that has a vibrant community because it is a good way of spreading the use of jsMath.

         
        • Davide P. Cervone

          Let me know if I can be of help.  I would do it myself, but my support time is very limited at the moment, and I don't want to start another project that will require maintenance.

          FYI, the jsMath/easy/load.js file is based heavily on the work I did for the Moodle jsMath filter.  Were I to do the Moodle filter today, the moodle/filter/jsmath/javascript.php file would simply load the jsMath/easy/load.js file, and all the configuration would be done through easy/load.js as it has virtually the same functionality.  (The only real difference is that there is no direct mimeTeX setting; instead, you have to add extensions/mimeTeX.js to the loadFiles list.)

          Good luck, and thanks for your support of jsMath.

          Davide

           
    • Gustav W Delius

      Gustav W Delius - 2007-07-14

      A first version of the jsMath module for Drupal now exists, see http://drupal.org/project/jsmath.

      Usually one would realise such a thing as a Drupal filter which can be attached to input formats in Drupal. That would then mean that the admin could enable the filter for some content types but not for others or even let the users choose whether they want to use have it used on their content or not. This I have not yet implemented in the module. Currently when the module is enabled all Drupal content is processed by jsMath. The reason for this is that it is not so easy to switch off universal processing. It would require me to be able to enclose the whole page in a div with CLASS="tex2math_ignore but this is not easy to do for a drupal module. It would be nice if global processing could be switched off with a jsMath option. It could then easily be switched on with CLASS="tex2math_process" where needed. Does such an option already exist?

       
      • Davide P. Cervone

        No, there is no such option already, but one could be added.

        An alternative would be for you to mark the sections you want to process by DIVs with a special CLASS, say CLASS="jsMath_process" since "tex2math_process" already has a meaning, and then in easy/load.js, change the "method" field to "ProcessSome" and finally add (either to easy/load.js or to the page itself) code to the effect of:

            jsMath.ProcessSome = function () {
              var div = jsMath.document.getElementsByName("div");
              for (var i = 0; i < div.length; i++) {
                if (div[i].className == "jsMath_process") jsMath.Process(div[i]);
              }
            }

        then this should cause only the marked div's to be processed after jsMath is loaded.  (Warning:  untested code; your mileage may vary.  In any case, this should give you the idea.)

        Thanks for making the drupal module.  I will add a link to it on the jsMath web page on the next round of updates to the web site.

        Davide

         
        • Gustav W Delius

          Gustav W Delius - 2007-07-15

          Davide, thank you very much for this suggestion. I will use it in the next release of the Drupal jsMath module. In that release I will also add user help below the input areas and this will link to a popup help page with a live preview area so that users can play around with the TeX syntax while composing their post.

           
          • Davide P. Cervone

            Sounds cool.  Let me know when you have it done.

            One of my projects that is waiting in the wings is an interactive math editor based on jsMath, but I'm just not finding time to work on it.  I had put together a little proof-of-concept application last December for a conference, which you can see at

                 http://www.math.union.edu/~dpvc/talks/2006-12-08.IMA/editor.html

            This is NOT a finished product, and there is still a lot of work to do (note in particular that there is no mouse interaction at the moment). It is only a week's worth of work, and I haven't been able to get back to it since then, even though I know it would be a useful thing for many people.

            Davide

             
            • Gustav W Delius

              Gustav W Delius - 2007-07-15

              Davide, your input tool demo is cool but I am not sure how to make it useful for people editing their content on the web. Most users there will use one of the WYSIWYG editors like TinyMCE, FCKeditor or HTMLarea and any tool for making TeX input easier would need to be integrated with these.

               
              • Davide P. Cervone

                I haven't gotten any details worked out yet, but I do plan on its being able to be called from other code, so that it would be easy to insert it into these types of editors. I envision it being just part of the rest of the WYSIWYG editor display, and when you click on the mathematics already being displayed by jsMath (in the editor, I would hope), you would be able to edit it in place on the page.   But, as I say, the exact details for that have yet to be worked out. 

                 
                • Gustav W Delius

                  Gustav W Delius - 2007-07-15

                  That would be quite spectacular! As a first step it would be interesting to figure out how one could toggle between TeX view and typeset view inside an HTML editor window. Personally I don't like palettes as input tools, but I certainly would like to be able to preview the typeset TeX inside the editor window.

                   
                  • Davide P. Cervone

                    I don't like palettes either, but they seem to be something that (some) people want.  Of course, the editor is set up to be able to do everything from keyboard entry as well (don't know if you tried that).  So you can type "sum" to get a summation symbol, and "int" for an intergral, "==>" for a double-long-right-arrow, etc.  This does present some interesting questions about how to treat deletions by backspaces, however.  For example, if you type sum to get a summation symbol, should delete get you back "su" or should delete the summation as a whole?

                    Note that in this format, you are not actually entering TeX code (you will never type "\frac" to get a fraction, for instance), so I'm not sure there is a need to see the TeX code, but I was planning to have an optional output window where you can see (and copy) the results if you want.

                    Since the editor is not tied to TeX in any way, it could also be used to generate MathML or other formats, if desired.  (The internal representation is actually a parsed formula, so it is not just layout, and could be used for content as well.)

                    As you can see, I have big plans. There is still a lot of work to do, through.

                     

Log in to post a comment.