Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Input Formatter - how to
Now I do so
and have to rewrite the code after forum updates.
I beleive there is a more applicable way to write a formatting wrapper.
/*=================================================
// forum\applications\vanilla\views\post\preview.php ,
// forum\applications\vanilla\views\discussion\helper_functions.php
==================================================
include_once ("/var/www/hosting/domains.com/htdocs/
forum_additions/BBCode2GeShi.php");
$Object->Body = fBBCode2Geshi($Object->Body, 0 , true);
$Object->FormatBody = Gdn_Format::To($Object->Body, $Object->Format);
$Sender->FireEvent('AfterCommentFormat');
$Object = $Sender->EventArguments['Object'];
echo fBBCode2Geshi($Object->FormatBody, 1 );
*/
and have to rewrite the code after forum updates.
I beleive there is a more applicable way to write a formatting wrapper.
0
Answers
You need to register the factory through a plugin. then enable it as the default formatter through config.
It is the Format column in the database that is applied. So if you want post in the past to have this formatter then you need to update those records.
I presume you have a problem with the BBCode formatter shipped with vanilla?
grep is your friend.
As for BBCode formatter - yes, I got some problem while connecting GeShi .
BBCode formatter in formatters chain makes text inside CODE tag unreadable for GeShi.
Besides I need some additional tags inside of [code]. So above there's my first working code - change [code]asdfasdf[/code] to ABACABADABACABA%nn, then format with inner vanilla bbcode formatters, then unpack ABACABADABACABA%nn from static array.
Actually i'm finding an external link to formatting chain.
Formatter is one at a time. Compound formatters made by registering a compound formatter, but I wouldn't do it this way.
But in any event this shouldn't be done in the views. Views are for output, not hunks of code.
grep is your friend.
[code]asdfasdfas[/code]
is contained in the database.and it is unpacked when user loades a page. i really need some formatter chain. so I have no way besides wrapper in the engine. it is not the best idea because of standarted tag names. but I'm interested how to use GeShi tag. also i need inner markup-tag to mark some code inside
[code][/code][GeShi][/GeShi].Do you know what model, controller, view is? Views aren't for putting large chunks of code in. This is bad practice.
I have given you advice about how to do it, if you choose to ignore that that is your problem. You have no need to register more formatters but might use the functionality for cosmetic reasons, just do as I explained.
Over and out.
grep is your friend.
Btw BBcode has no standard. that is why I don't encourage it.
grep is your friend.
Is really BBCode is a bad practice in the Internet ?
Of course I understand that CPU works much more, while unpacking text from BBCode to HTML to show page content. But my additional not huge formatter is no problem when we have been already running bbcode plugin in
Gdn_Format::To($Object->Body, $Object->Format);
You may visit a lot of bbcode sites and the main list of tags is standarted. For showing sources are usually used tags [SRC] and [CODE].ps
I'm ready to change CODE to SRC
There was an error rendering this rich post.
So I need NNBC to work with [GeShi][/GeShi] tag and not let NNBC to damage text inside of this tag.
grep is your friend.
grep is your friend.
Ckeditor and geshi can be used.
Incidentally i released over twenty bbcode plugins for vb.org when i was coding for vb
There was an error rendering this rich post.
- Pre-format by changing [code][/code] into recoverable format.
- Allow standard formatting to take place
- Post-format with GeShi
That is all the help I can give you.grep is your friend.
grep is your friend.
No, not plugin -
<?php /*==================================================================== // preview.php , // forum\applications\vanilla\views\discussion\helper_functions.php //==================================================================== include_once ("/var/www/hosting/domain.com/htdocs/forum_additions/BBCode2GeShi.php"); $Object->Body = fBBCode2Geshi($Object->Body, 0 , true); $Object->FormatBody = Gdn_Format::To($Object->Body, $Object->Format); $Sender->FireEvent('AfterCommentFormat'); $Object = $Sender->EventArguments['Object']; echo fBBCode2Geshi($Object->FormatBody, 1 ); */ if (class_exists("GeSHi")==false){ include ("/var/www/hosting/domain.com/htdocs/geshi/geshi.php");} function fBBCode2Geshi ($s, $mode, $showlines) { if (1==1) { //clear WYSIWIG trash $s=preg_replace("@ @"," ",$s); $s=preg_replace("@]<\/p[/>]@","\n",$s); $s=preg_replace("@]@","\n",$s); $s=preg_replace("@]@","",$s); $s=preg_replace("@<\/p[/>]@","\n",$s); $s=trim($s); } $CHANGE_NN="_ABACABAiiiDABACABA_"; $DEVIDER="_a789qwertyFF_"; static $STATIC_ARR_CODE; if ($mode==0) { $STATIC_ARR_CODE=''; $regexp_code = "/\[CODE](.*)\[\/CODE]/imsU"; preg_match_all($regexp_code, $s, $matches); $arr=$matches[0]; $maxarr=count($arr)-1; if (!empty($arr)) { for ($i=0; $i <= $maxarr; $i++) { $s=preg_replace($regexp_code,"$CHANGE_NN$i%",$s,1); //cut off [code] and [/code] $code=$arr[$i]; $len=strlen($code); $val=substr($code, 6, $len-13); // // get GeShi <div> // $language = 'vb'; $code = htmlspecialchars_decode($code); $geshi = new GeSHi($code, $language); $geshi->enable_keyword_links(false); $geshi->enable_classes(); $output .= ""; $output .= ""; $output .= ""; $output .= $geshi->parse_code(); $output .= ""; $output .= ""; unset($geshi); $output .= ""; // SAVE TO STATIC ARRAY $STATIC_ARR_CODE = $STATIC_ARR_CODE.$output.$DEVIDER; } // FOR }// EMPTY } else { // // RESTORE FROM ARRAY // $arr=explode($DEVIDER,$STATIC_ARR_CODE); if (!empty($arr)) { $maxarr=count($arr)-1; for ($i=0; $i <= $maxarr; $i++) { $CODE=$arr[$i]; $s=preg_replace("/$CHANGE_NN$i%/",$CODE,$s); } } } //ELSE ENDIF return $s; } //end function ?>
grep is your friend.
$String="0".$String."0";
add this string before
return $String
in ParseSyntax - and you'll see some surprise;