Info
- 6 posts
- 3 voices
- Started 5 years ago by dprice
- Latest reply from Trent Adams
- This topic is not resolved
MathML and BBpress working together
-
- Posted 5 years ago #
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('') . '</code>'", $text); // $text = preg_replace("|\n<code>(.*?)</code>|se", "'<pre><code>' . encodeit('') . '</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.
-
- Posted 5 years ago #
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 5 years ago #
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 5 years ago #
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 5 years ago #
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 5 years ago #
Created a TRAC for it and it is in your other thread!
Trent
-
You must log in to post.