WordPress Math Publisher Plugin Support

Ron Fredericks writes: This is just a short post to point my readers to a new mathematics publishing plugin available from ECI’s Blog Center. This plugin offers a simple alternative to the more standard approaches: XML’s MathML and Math into LaTeX.

WordPress Math Publisher plugin home page
www.embeddedcomponents.com/blogs/wordpress/wpmathpub/

Usage

An example of how it can be used is your blog posts:

WordPress code…
[pmath size=16](a^2+b^2)=a^2+2ab+b^2[/pmath]
where:
[pmath size=12]~a[/pmath] is defined as a
[pmath size=12]~b[/pmath] is defined as b

Results in:

(a^2+b^2)=a^2+2ab+b^2

where:
~a is defined as a
~b is defined as b

References:
  Pascal Brachet’s phpmathpublisher
    Home: www.xm1math.net/phpmathpublisher/
    Usage: www.xm1math.net/phpmathpublisher/doc/help.html
  Matteo Bertini’s WordPress plugin called PHP Math Publisher
    www.slug.it/naufraghi/programmazione-web/wpmathpublisher
  Randy Morrow’s WordPress plugin called Axiom
    wordpress.org/extend/plugins/axiom/#post-2794

Technorati Tags: , , , , , , , , , , ,

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • scuttle
  • Slashdot

27 Responses to “WordPress Math Publisher Plugin Support”

  1. LectureMaker Says:

    How to Display Math Symbols in WordPress…

    Ron Fredericks writes: Have you ever wanted to include math equations in your blog posts or lecture materials?  Here is an easy and slick way to get the job done.  Use Embedded Components new WordPress plugin called WordPress Math Publisher, or wp…

  2. Ron Fredericks Says:

    The difference between MathML, LaTeX, and PHP Math Publisher…

    Each of these methods may be used to display mathematical equations on a web page. Both MathML and LaTeX follow standards that have communities of users around them. Unfortunately they both require some significant overhead to use and/or view.

    My new plugin called WordPress Math Pub, is based on the PHP Math Publisher library by Pascal Brachet. MathML and LaTeX are not used. This library is an open-source library that converts plain text into image links to mathematical PNG images. The PHP Math Publisher library is a relatively new method for publishing mathematic equations and symbols. It has its own simple text-based syntax that is easy to learn and embed into any web page. New math images are created automatically on the fly from within your WordPress main loop as needed during content display.

  3. rjmatm Says:

    Sorry for not getting back to you. I’ve been out of the loop for a while. The thing with word press is the it’s tough for me to figure out how to post the plug-in on their site. I want to give my plug-in away for free (Free Software style). So please don’t think I’m hiding, I’ve just been having trouble with subversion.

    Randy

  4. Ron Fredericks Says:

    Hi Randy:

    Here were the steps I took to complete my WordPress plugin:

    1) Prepare the special readme.txt with wiki markdown tags such that the WordPress landing page has all content needed: description, installation, FAQ, screenshots, other notes.

    2) Follow their SVN beginners guide to stuffing the trunk subdirectory on my local PC with all my plugin code. I had two problems with this initially:

    a) This plugin requires the use of an img/ subdirectory that must be on the blogger’s system, but empty subdirectories are ignored (during the download process by a new user trying to aquire my plugin) unless you load something in there. So I put a dummy image in the img/ directory just so users will get that directory. I included the directory structure in my screenshots to help new users quickly understand the details surrounding my plugin, in case they forgot to upload all supporting files and subdirectories onto their server:
    http://wordpress.org/extend/plugins/wpmathpub/screenshots/

    b) When I tried to commit my initial code to the WordPress repository, several errors were encountered by the SVN CI command. The only help I found was a reference on some site “that an engineer should not upload too much code at once or problems may occur” - and yup problems did occur. To solve these errors, I repeated a series of “stat, del, cp, and ci” statements (not always in that order), until the stat command gave no errors. Then I did a download from my new wordpress.org landing page to see what files I was missing as a result of my “get rid of the SVN errors at all cost” technique. I then did one more round of cp, stat, and ci SVN commands to complete the process.

    I hope that helps,

    Ron

  5. Roderik Says:

    I tried the plugin but it interferes somewhat with the editor (both tinymce as well as fckeditor). The

  6. Ron Fredericks Says:

    Hi Roderik:

    Can you provide some detail on how wpmathpub plugin interferes with your use of the editors?

    So far the only issue has been in the use of greater than “>” and less than “<” symbols - as these are converted by html aware editors to “&amp gt;” and “&amp lt;”. This conversion of html symbols can be circumvented by switching from “edit” mode to “code” mode.

    Bes regards,

    Ron

  7. Roderik Says:

    Switching to code mode does not circumvent it for me. When you edit in code, click save and check what is there, < and > were inserted. The only way might be to turn of the visual editor as a whole in the user settings. However that is quite annoying since I want to write the articles itself in the visual editor.
    I think it might work if you write a filter for wordpress that converts the html encoded characters if they are inside a math block.

  8. Roderik Says:

    & lt; and & gt; instead of in last message

  9. Ron Fredericks Says:

    Hi Roderik:

    Thank you for your polite and accurate feedback.

    I agree with you that it should be fairly simple to implement the html entities replacement - as you suggest above. I will use our conversation here to drive the next release. It will take me a week or so to get back to this project with a formal update release on the wordpress.org site.

    Ron

  10. Oliv Says:

    Hi,

    Following the previous comments, when using > or < it breaks the post display.

    But I am posting comment here to suggest to had math support for comments.
    For example by adding that:

    add_filter('comment_text', 'to_phpmath', 5);

    at the end of wpmathpub.

    @+Oliv

  11. Ron Fredericks Says:

    Hi Oliv:

    Adding math support to comments is a great idea. I am adding this to the list of TODO’s for a new release comming soon.

    Best regrards,

    Ron

  12. Ron Fredericks Says:

    I just checked wpmathpub plugin against Wordpress 2.5.1. It works just fine. This change to the readme file will be added to the next release comming soon - too.

    Best regards,

    Ron

  13. Oliv Says:

    Re-,

    Correction from my previous comment:

    The following sequence between pmath tags breaks either comment either post:

    } >

    as for:

    sum{i=1}{n}{C(q_i)}>C(sum{i=1}{n}{q_i})

    Best regards,

    Oliv,

  14. Ron Fredericks Says:

    I have made two updated candidate changes to my wpmathpub v: 1.0.4 plugin to address the issues presented by Roderik and Oliv in comments above:

    1) With this first change, html entities such as “& gt;” are now decoded back to their correct ASCII values. The php function html_entity_decode(), does all the heavy lifting. This was a great idea initiated by Roderik in his comments above. In the GeSHI code highlighter box below you can click on this function name to learn more…

    HTML entity decoder fixed in wpmathpub.php plugin

    Code (php)
    1. $phpmath = mathfilter("<m>".html_entity_decode($ascii_math)."</m>", $size_math, $abs_dirimg);
    2. // this line replaces the old line
    3. // $phpmath = mathfilter("<m>".$ascii_math."</m>", $size_math, $abs_dirimg);

    2) With this second change, wpmathpub tags [pmath size=xx] can be used in blog posts and in comments too, as this comment demonstrates below. To affect the support for pmath tags in comments, only one new line of code was needed. This was a great idea by Oliv in his comment above. See the new line of code in the GeSHI code highlighter box below…

    pmath tag support for comments added in wpmathpub.php

    Code (php)
    1. // Register our filter, to_phpmath, into the hook routines, the_content and comment_text.
    2. // Note: the ", 5" priority add_filter function parameter was removed on 5/16/08 to correct display of text after pmath tags when HTML entities are decoded
    3. //           Register comment_text updates after all priorty content processing filters.
    4. //            Note: the order of calling the comment filter first, before the content filter, fixed comment RSS feed errors
    5. add_filter(‘comment_text’, ‘to_phpmath’);
    6. //           Register the_content updates after all priorty content processing filters.
    7. add_filter(‘the_content’, ‘to_phpmath’);

    I discovered and resolved two issues before pmath tags would work properly once comment support was added:

    • Priority of the comment and content filters had to be set to the add_filter function default priority level i.e.: no hard coded priority parameter for add_filter() function. Otherwise, content after the first pmath tag will not display.
    • Order of the filter processing had to start with comment processing, followed by content processing. Otherwise the comment RSS feed could fail with an invalid tag error.

    Demonstration

    So Oliv’s pmath test case (with a “& gt;” entitiy hard coded)…

    sum{i=1}{n}{C(q_i)}>C(sum{i=1}{n}{q_i})

    and the same test case (with a “>” symbol hard coded)…

    sum{i=1}{n}{C(q_i)}>C(sum{i=1}{n}{q_i})

    now display correctly with the “&amp gt;” entity converted back to text for correct conversion to mathematic symbols…

    sum{i=1}{n}{C(q_i)}/>C(sum{i=1}{n}{q_i})

    and with “>” symbol …

    sum{i=1}{n}{C(q_i)}/>C(sum{i=1}{n}{q_i})

    How to get the code changes

    If you want to make the changes to your own plugin now, all you have to do is copy the two code snippets above. Then, put them into the current wpmathpub download, version 1.0.4, as I did to make this comment work correctly with html entities. While, a new download under Wordpress.org’s subversion control will be coming out soon.

    Best regards,

    Ron

  15. Ron Fredericks Says:

    Math equations within Wordpress blog comments are now supported in the wpmathpub plugin official release on WordPress.org web site here:

    http://wordpress.org/extend/plugins/wpmathpub/

    Thanks again for everyones’ suggestions leading to the new release of this plugin, as seen on this support page above, or by google searching “wpmathpub”.

    Best regards,

    Ron

  16. Writing Mathematical Formula With WordPress Math Publisher Plugin Says:

    [...] WordPress Math Publisher plugin is really exciting for me, especially I am now able to write formula in WordPress. It works almost [...]

  17. jnetter Says:

    Hi Ron,

    Very cool plugin, but I’m having a problem. Wpmathpub installed and ran fine on my localhost server, but when installed on my website, posts don’t load past the post heading (title, date, etc.). Page loading just hangs at this point. No error message, just fails to complete loading.
    Tried the normal stuff: deactivate/activate, disable other plugins, switch to default theme, delete and reinstall the plugin files, no luck. Images are not being written to img directory (which is 755).
    wpmathpub 1.06, wp 2.51
    Any suggestions?

  18. Craig Rose Says:

    Hi

    Have never used the plugin before so don’t know what to expect. I’m getting

    Error: wpmathpub plugin not usable under these conditions: http://www.craigsmaths.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/

    for S(f)(t)=a_{0}+sum{n=1}{+infty}{a_{n} cos(n omega t)+b_{n} sin(n omega t)}

    This is on WP 2.6 so is this a compatibility problem or something else?

    Thanks

  19. Ron Fredericks Says:

    Hi Craig:

    As you can see from the display, your [pmath ...] tag works fine on my blog. As you point out, I am using Wordpress 2.5.1. I have tested several prior versions but have not yet had a chance to verify compatibility with 2.6 yet. It could take another two weeks before I make this test.

    In the meantime I do have a diagnostic version of the plug-in that helps identify potential sources of error based on installation and damaging effects from other plug-ins. I could email this version to you if you like?

    Best regards,

    Ron

  20. Ron Fredericks Says:

    With over 700 downloads of wpmathpub, I decided I should continue to support this plugin. Version 1.0.7 has just been released to wordpress.org’s plugin pages. The new version includes a diagnositc display to help new users resolve their initial install problems.

    You can get it here:
    http://wordpress.org/extend/plugins/wpmathpub/

    Best regards,

    Ron

  21. Tyler Says:

    Hi there.. i really like this plugin, but i have what i hope is a simple question.

    my blog’s background is black, and the theme i am using is trying to put the output in a light grey and is messing things up. is there a way to have the output in white? or any color for that matter….

    -tyler

  22. Ron Fredericks Says:

    Hi Tyler:

    What you ask for seems obvious in hindsight, thanks for the suggestion. Control of forground color, background color, and both of these color transparencies, is very “do-able” since all controls are handled by the PHP GD library. The necessary step is to add these color controls as seen on http://www.php.net into the wpmathpub.php plugin code:

    imagecolorallocate
    imagecolortransparent
    imagecolorallocatealpha

    I will put this feature request on the list for next release.

    Best regards,

    Ron

  23. AB Says:

    Besides being able to control the background (I believe transparent background is the most useful), we also need the plugin to add a special CSS image style so that we can control the appearance of the math separate from the style of the rest of the images.

    In my blog I have my images surrounded by a frame so the math shows up with the frame as well.

    Ideas?

  24. Ron Fredericks Says:

    Hi AB:

    Adding more style control is a good idea. I’m still wrapping my head around your suggestion with respect to actionable features. For example: below is what the HTML code looks like from Craig’s inline math comment above (with angle brackets removed to insure no rendering action takes place):

    img src="http://www.embeddedcomponents.com/blogs/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_965_6427aababa4e7b39af22b31fc6504152.png" style="vertical-align:-35px; display: inline-block ;" alt="S(f)(t)=a_{0}+sum{n=1}{+infty}{a_{n} cos(n omega t)+b_{n} sin(n omega t)}" title="S(f)(t)=a_{0}+sum{n=1}{+infty}{a_{n} cos(n omega t)+b_{n} sin(n omega t)}"

    From the code you can see the existing style control calculated on the fly to best fit the surrounding text:

    • style=”vertical-align:-35px;
    • display: inline-block;

    Are you proposing the addition of some class=”id_thing” entries that are configurable as part of the wpmathpub blog plugin?

    Best regards,

    Ron

  25. AB Says:

    What I am proposing is that the math images are (maybe optionally) tagged as some class=”mathpub_img” or something so that we can control their CSS style separately from the “img” class.

    Maybe you have a better idea. What I want is for my equations to show as transparent BG (or at least BG color) while my regular images show with a frame around them.

  26. Ron Fredericks Says:

    Oops:

    One new user posted a message explaining how wpmathpub failed to configure itself properly. The user was very clear in showing the path details and what he did to solve this error. This type of error caught my attention after 1000 new uers have downloaded my plugin with nearly all having an error free experience.

    Sorry but I deleted you by mistake. Please post again if you get a chance. In the mean time, I will try a few combinations on my own. If I find any issue in my config system, I will roll a fix into the next release.

    Best regards,

    Ron

  27. Ron Fredericks Says:

    Hi AB:

    Thanks for clarifying the CSS style feature you are proposing. I will be experimenting with this over the next few weeks.

    Best regards,

    Ron

Leave a Reply