Great module!

I am working for a math forum and they want to install a custom bbcode to allow latex formulas. I have to use the following:
tag name: [math] [/math]
replacement:
?{param}

And thats it. How would I be able to achieve this?

Thanks a bunch!

Comments

ablank’s picture

I tried hacking bbcode-filter.inc, but I think I'm overlooking something, it doesn't changes anything.... But there are the defenitions of the supported tags.

ablank’s picture

Here is my addition:

// begin processing for [spoiler]
  if (stristr($body, '[spoiler=') !== FALSE) { // prevent useless processing
    $arr = array(
      'tag'         => 'spoiler',
      'pattern'     => '\\[spoiler\\](.*?)\\[/spoiler\\]',
      'replacement' => '<a href="#" class="spoiler">Spoiler: <span>$1</span></a$
      'text'        => $body);
    $body = _bbcode_replace_nest_tag($arr);
  } // end processing for [spoiler]

+ Additional CSS code in my template

I think this should work... But I think I've to enable it somehow...

naudefj’s picture

Ablank, if you are proposing a new tag, please submit a patch for it.

ablank’s picture

I would be proud to submit a patch because its a really nessary tag and I want to provide it with the world, BUT FIRST IT SHOULD WORK ;)

Any ideas are welcome :)

chasz’s picture

no help on the syntax?

naudefj’s picture

Status: Active » Postponed

Unfortunately I don't have time to help you with the code. However, when done, you are welcome to submit a patch for it.

iams83’s picture

Version: 5.x-2.1 » master

I have patched my own web, and works fine for me: http://www.razonaurea.com. It makes use of the service http://www.texify.com

Please, test it and submit this patch.

All changes are in bbcode-filter.inc:

     '#\[youtube\]([0-9a-zA-Z_\-]+)\[/youtube\]#si'                 => '<object width="425" height="366"><param name="movie" value="http://www.youtube.com/v/\\1"></param><embed src="http://www.youtube.com/v/\\1" type="application/x-shockwave-flash" width="425" height="366"></embed></object>',
+    '#\[math(?::\w+)?\](?:[\r\n])*(.*?)\[/math(?::\w+)?\]#sie'   => '_bbcode_math_tag(\'\\1\')',
     
     // Table tags
     '#\[table\](.+?)\[/table\]#si'                           => '<table class="bb-table">\\1</table>',

And after _bbcode_php_tag function:

+     function _bbcode_math_tag($text = NULL) {
+       return '<img alt="'.$text.'" src="http://texify.com/img/'.urlencode(str_replace('+', '%2B', $text)).'.gif" />';
+     }

Thank u,
Ismael