bbPress

Simple, Fast, Elegant

bbPress support forums » Plugins

MathML and BBpress working together

(6 posts)
  • Started 1 year ago by dprice
  • Latest reply from Trent
  • This topic is not resolved
  1. Being both a web nerd and Physics student, I decided it was time for BBpress to meet up with MathML.

    Here's the steps I took to get it crankin':

    1. Made a copy of the default 'kakumei' template, then renamed the folder 'physics', my new template name. I then put a copy of ASCIImath.js in there. This does all the hard work.
    2. Changed the physics/header.php from:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" <?php bb_language_attributes( '1.1' ); ?>>

      to:

      <?xml version='1.0' encoding='iso-8859-1'?>
      <?xml-stylesheet type="text/xsl" href="http://www.w3.org/Math/XSL/mathml.xsl"?>
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
      
      <html xmlns="http://www.w3.org/1999/xhtml"
            xml:lang="en"
            xmlns:pref="http://www.w3.org/2002/Math/preference"
            pref:renderer="css">

      It'd probably still work if you didn't bother with this step, but seeing as BBpress is making XML we may as well.

    3. Added <script type="text/javascript" src="<?php echo bb_path_to_url( dirname(__FILE__) . '/ASCIIMathML.js'); ?>"> to physics/header.php - this loads the ASCIIMathML.js javascript and does a majority of the MathML magic.
    4. Opened bb-includes/formattingfunctions.php and edited this:
      function code_trick( $text ) {
      	 $text = str_replace(array("\r\n", "\r"), "\n", $text);
      	// $text = preg_replace("|<code>(.*?)</code>|e", "'<code>' . encodeit('$1') . '</code>'", $text);
      	// $text = preg_replace("|\n<code>(.*?)</code>|se", "'<pre><code>' . encodeit('$1') . '</code></pre>'", $text);
      	return $text;
      }
      To turn off the backtick code replacement - this is what ASCIIMath.js does!

    That was it. I'll zip it all up then post it up here. Ideally, it'd be better to not comment out any of the bb-include/ files - if anyone has any suggestions, let me know.

    Posted 1 year ago #
  2. Oh yeah - you can have a play at http://www.thetelegraphic.com/bbpress/bbpress/
    That's really just a sandbox for now and won't be there forever.

    I'll be releasing the black template it's using too - It's just Kakumei with a different colour scheme.

    Posted 1 year ago #
  3. Get bbpress + mathML.

    This is really just a quick knockup - perhaps MathML support would be best in plugin form? I really didn't do all that much, but I'm not familiar with the BBpress plugin system at all so I'm not sure how easy (if possible), it would be.

    Posted 1 year ago #
  4. Thanks!

    You can include ASCIIMathML.js in the header via plugin by this sort of code:

    `function incMathJs() {
    $url = bb_path_to_url( dirname(__FILE__) . '/ASCIIMathML.js')
    echo '<script type="text/javascript" src="' . $url . '">';
    }
    add_action( 'bb_head', 'incMathJs' );

    Not sure when or how the JS kicks in, but perhaps that's not necessary? Anyway, you could head over to trac and request that code_trick be made pluggable (so a plugin could overwrite it).

    Posted 1 year ago #
  5. Ah - so ridiculously easy! I'm liking BBpress more and more ;).

    I just requested code_trick to become pluggable too - hopefully that'll happen, and soon, so I can just use a plugin and not hack at core files.

    Posted 1 year ago #
  6. Created a TRAC for it and it is in your other thread!

    Trent

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.