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':
- 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.
- 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.
- 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. - Opened bb-includes/formattingfunctions.php and edited this:
To turn off the backtick code replacement - this is what ASCIIMath.js does!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; }
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.