Python Forum

Full Version: idea for code boxes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
for code boxes, especially big ones, how about "_X" in the upper right corner to minimize the box or make it go away entirely?
I have been trying to figure out a way to auto wrap it in spoiler tags in the event its 50 lines or more. In that way you could shrink it entirely.
Perhaps something like this:
$excode = explode("\n", $code);
if(count($excode) >= 50)
{
// spoiler stuff here
}
Replace with the correct variable name though.
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;

}       
(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?