>>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()