MyBB Community Forums
How auto wrap text if text has more than 10 lines - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: 1.8 Support (https://community.mybb.com/forum-175.html)
+--- Forum: General Support (https://community.mybb.com/forum-176.html)
+--- Thread: How auto wrap text if text has more than 10 lines (/thread-204152.html)



How auto wrap text if text has more than 10 lines - metulburr - 2016-10-04

We are using a custom BBcode (spoiler tag [spoiler], as well as a code syntax highlighter tag[python] ). We want to auto wrap the python tags in spoiler tags in the event that the text between the python tag is (whichever is easier) more than X characters or more then 10 newlines.


so for example:


[python]
def func:
    pass
[/python]

would stay the same

whereas the following code

[python]
import sys
import math
 
stderr = sys.stderr
stdout = sys.stdout
 
def main():
    write_limit = 10000
 
    # Get 0 or 1 or 2 arguments (defaults: 0 and 0)
    this_arg = '0'
    digits_max = 0
    if len(sys.argv) > 1:
        this_arg = sys.argv[1]
        if len(sys.argv) > 2:
            digits_max = int(sys.argv[2])
[/python]

would auto switch to


[spoiler=(click to expand code)]
[python]
import sys
import math
 
stderr = sys.stderr
stdout = sys.stdout
 
def main():
    write_limit = 10000
 
    # Get 0 or 1 or 2 arguments (defaults: 0 and 0)
    this_arg = '0'
    digits_max = 0
    if len(sys.argv) > 1:
        this_arg = sys.argv[1]
        if len(sys.argv) > 2:
            digits_max = int(sys.argv[2])
[/python]
[/spoiler]