Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Babby's First BBCode Generator

Name: Anonymous 2012-06-06 1:28

Get the fuck out.

Name: Anonymous 2012-06-06 5:06

>>13
I think everyone [tt]should[/tt] [tt][tt]write[/tt][/tt] one.

import random, sys, re, [tt]random[/tt]

def inBBCode(word, bbcode):
    return '[' + [tt]bbcode[/tt] [tt]+[/tt] ']' + [tt][tt]word[/tt][/tt] + [tt]'[/'[/tt] [tt][tt]+[/tt][/tt] [tt]bbcode[/tt] + ']'

bbcodes = ['sup', 'sub', 'b', 'i', [tt]'u',[/tt] 'tt', 'spoiler', 'o']

txt = open(sys.argv[1], [tt]'r').read()[/tt]
matches [tt][tt]=[/tt][/tt] re.findall(r'([^ \n\t]+)([ \n\t]+)?', txt)
for [tt]m[/tt] in matches:
    word [tt]=[/tt] m[0]
    while random.randint(0, 5) < random.randint(0, [tt]8):[/tt]
        word = inBBCode(word, bbcodes[random.randint(0, len(bbcodes) - 1)])

    sys.stdout.write(word)
    sys.stdout.write(m[1])
    sys.stdout.flush()

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List