Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 syntax highlighting
#21
Made a regex for pre tag in MyCode and deactivated HTML in post.
Still the same problem.

HTML is off witch is better for security.
<h2>test</h2>

[pre class="brush: python"]
print('hello world')

print("test")
[/pre]
[pre class="brush: python"]
print('hello world')

print("test")
[/pre]
Found this info.

Quote:Note that in MyBB, you have to be careful with style tags because linebreaks are automatically converted into <br />
and so your style will have <br /> tags inside it
Not to happy about this automatic stuff :@
So maybe a post to MyBB staff and ask if there is a way to turn it off.
See that in php of v3 they have some cleaning $text = str_replace ( "\n", "", $text).
So maybe have to clean it in some way.
Quote
#22
Nice job.
Will do.
Quote
#23
So i have looked more into this.

<?php
echo nl2br("foo isn't\n bar");
?>

Out:
foo isn't<br />
bar
Link MyCode.
$options['nl2br'] Each line break will be transformed into a html line break (<br />), if this option is set to 1
So it's set to 1.

It's defined in class_parser.php
What i am unsure about is that options = array( is comment out.
Tried only to un-uncomment  nl2br,but that lock forum down :-/
In line 212 i tried to set 1,but did't help.

Think maybe i have to un-uncomment whole array and set values for each  :s
Quote
#24
[pre class="brush: python"]
print('hello world')

print("test")
[/pre]


To keep changelog.
I commented that entire if condition out. It appears to have worked. Im not sure of any unwanted side effects that might of caused (if any) 


        //if(!isset($this->options['nl2br']) || $this->options['nl2br'] != 0)
        //{
        //  $message = nl2br($message);
            // Fix up new lines and block level elements
        //  $message = preg_replace("#(</?(?:                                                            html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)\s*  <br />#i", "$1", $message);
        //  $message = preg_replace("#(&nbsp;)+(</?(?:                                                   html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)#i", "$2", $message);
        //}
EDIT: I get it, then you lose ALL newlines. Ill revert back for the time being
Quote
#25
Im crappy at regex, but what if we added a condition that replace newlines with breaks if not within pre tag?
Quote
#26
I tried cleaning inside of pre tags only. It keeps the rest of the post fixed, and removes the newlines from within the pre tags. However the break tags still remain
   

function my_nl2br($string){
$string = str_replace("\n", "<br />", $string);
if(preg_match_all('/\<pre\>(.*?)\<\/pre\>/', $string, $match)){
    foreach($match as $a){
        foreach($a as $b){
        $string = str_replace('<pre>'.$b.'</pre>', "<pre>".str_replace("<br />", "", $b)."</pre>",       $string);
        } 
    }
}   
return $string;
}
apparently other people have the same problem
http://stackoverflow.com/questions/82174...sing-nl2br
Quote
#27
Oh wait i think i might of got it. How does that look? Anything wrong? All newlines correct and as expected?

First line
second line

fourth line

sixth line

import pygame as pg
import sys
 
class States(object):
    def __init__(self):
        self.done = False
        self.next = None
        self.quit = False
        self.previous = None
 
class Menu(States):
    '''
     test
    '''
    def __init__(self):
        States.__init__(self)
        self.next = 'game'
    def cleanup(self):
        print("cleaning up Menu state stuff")
Although it still does not copy from the codebox correctly. But only in the advanced editor. You can copy and paste it into the quick reply no problem. So whats different?
Quote
#28
Very good what did you do :cool:

Quote:Although it still does not copy from the codebox correctly.
That should be an easier fix,maybe just use the button from V3 and make it insert.
[pre class="brush: python"]

[/pre]
Shall look more into it later today,it's midnight theme i have build with here.
[pre class="brush: python"]
print('hello world')

print("test")
[/pre]

[pre class="brush: python"]
import dataset

player_lst = [
    {'name': 'Superman', 'score': 9999999},
    {'name': 'Hulk', 'score': 2000001},
    {'name': 'Batman', 'score': 500055}
    ]

db = dataset.connect('sqlite:///heroes.db')
table = db['Score_table']
for item in player_lst:
    table.insert(item) 
[/pre]

[pre class="brush: python"]
from collections import deque
from itertools import islice

def window(iterable, size=2):
   iterable = iter(iterable)
   d = deque(islice(iterable, size), size)
   yield d
   for x in iterable:
       d.append(x)
       yield d
[/pre]
Quote
#29
I made a BBCode for that so we dont have to keep typing in the class brush python etc.
it should be

[python]CODE HERE[/python]
The actual button for it is currently in the new drop down BBcode Button
Quote
#30
Okay good.
But now it's 4 click to insert code,should be 2 as other.
Maybe look at own button for this.

Really nice to see it work :)
Have not time now shall look more into it later.

print('hello world')

print("test")
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  feature request: highlighting Skaperen 9 2,115 Jan-26-2017, 04:13 PM
Last Post: Kebap

Forum Jump:


Users browsing this thread: 1 Guest(s)