Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
idea for code boxes
#5
(Nov-03-2016, 01:39 PM)metulburr Wrote: my problem was that i have not been successful at making spoiler html code. All current spoiler tags are handled by the hazSpoiler plugin. And even after looking at the code, im not sure how to replicate it. 

Ive tried some custom mycodes such as
https://jsfiddle.net/fy452ct3/3/


i tried somehting like this a bit ago
function my2_nl2br($string){
    $cutoff = 250;
    $string = str_replace("\n", "<br />", $string);
    if(preg_match_all('/\<pre class="brush: python"\>(.*?)\<\/pre\>/', $string, $match)){
        foreach($match as $a){
            foreach($a as $b){
                $string = str_replace('<pre class="brush: python">'.$b.'</pre>','<pre class="brush:      python">'.str_replace("<br />", "\n", $b)."</pre>", $string);
                if (strlen($b) > $cutoff){
                        $string = "[spoiler]" . $string . "[/spoiler]";
                    }
                }
            }
        }
            
    return $string;

}       

Is it working?
Reply


Messages In This Thread
idea for code boxes - by Skaperen - Nov-03-2016, 04:38 AM
RE: idea for code boxes - by metulburr - Nov-03-2016, 04:47 AM
RE: idea for code boxes - by Dragonexpert - Nov-03-2016, 12:59 PM
RE: idea for code boxes - by metulburr - Nov-03-2016, 01:39 PM
RE: idea for code boxes - by Root13 - Nov-03-2016, 02:19 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020