Problem with bbcode and generate_text_for_display

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
geomar
Registered User
Posts: 3
Joined: Fri Jan 27, 2017 7:42 pm

Problem with bbcode and generate_text_for_display

Post by geomar »

I want to do a kind of custom parsing of certain bbcode tags and replace them with images which are created by the server using tex-live engine for lateX. I succeeded in doing that inside function generate_text_for_display (file functions_content.php) where I replaced the bbcode with the image I wanted.The problem is that although this "custom bbcode parsing" I did works fine on viewtopic,it doesn't work on preview mode. So I was wondering,what do I have to do in order to modify the text BEFORE it is displayed in preview mode?I was assuming that the function generate_text_for_display was used for preview as well but it appears it isn't.

Thanks in advance,
George
User avatar
Ger
Registered User
Posts: 2117
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100

Re: Problem with bbcode and generate_text_for_display

Post by Ger »

I have a working dedicated extension for a science related board, part of which holds a LaTeX BBcode. It doesn't require you to modify core files, so I think you'll be better off with it.

It's quite rough ATM, but the LaTeX part works. It uses the core.text_formatter_s9e_configure_before event, where I do:

Code: Select all

$usage = '[tex hash={ALNUM;useContent}]{TEXT}[/tex]';
		$template = '<img class="bbc_img" src="./images/latex/pictures/{@hash}.png" alt="LaTeX" />';
		$event['configurator']->BBCodes->addCustom($usage, $template);
		$event['configurator']->tags['tex']->attributes['hash']->filterChain->prepend('\ger\sciencebbcode\helpers\tex_helper::generateHash');
The $tex_helper::generateHash($formula) processes the LaTeX code input to a Tex doc, which is converted to an image that's stored with a MD5 hash of the input as filename.

If you're interested, I can see if I can make this available on Github. I need to check license stuff for this though, since I use a LaTeX Rendering Class by Benjamin Zeiss from 2003 (but reworked to work on PHP 5.5).
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-

Return to “phpBB Custom Coding”