MyBB Community Forums

Full Version: How auto wrap text if text has more than 10 lines
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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]