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

Pages: 1-4041-

Command line BB generator

Name: Anonymous 2011-08-10 0:49

$ bb -h | bb -code
usage: bb [-h] [-b] [-i] [-o] [-u] [-s] [-m] [-spoiler] [-sub] [-sup] [-aa]
          [-code] [--faggot] [--mode {all,random,ransom}]
          [text [text ...]]

BBCode encode user input.

positional arguments:
  text                  text to be encoded

optional arguments:
  -h, --help            show this help message and exit
  -b                    insert bold tag
  -i                    insert italics tag
  -o                    insert overline tag
  -u                    insert underline tag
  -s                    insert strikethrough tag
  -m                    insert monospace tag
  -spoiler              insert spoiler tag
  -sub                  insert subscript tag
  -sup                  insert superscript tag
  -aa                   insert Shift JIS tag
  -code                 insert code tag
  --faggot              insert ``faggot'' quotes
  --mode {all,random,ransom}
                        special modes for applying all tags to the text, a
                        random selection of tags to the text, or a random
                        selection of tags to each character of the text.

$ cat ~/bin/bb | bb -code
#!/usr/bin/env python

import argparse
import random
import sys


_TAG_DESC_PAIRS = [
        ('b', 'bold'), ('i', 'italics'), ('o', 'overline'), ('u', 'underline'),
        ('s', 'strikethrough'), ('m', 'monospace'), ('spoiler', 'spoiler'),
        ('sub', 'subscript'), ('sup', 'superscript'), ('aa', 'Shift JIS'),
        ('code', 'code')]


_TAGS = [tag for tag, desc in _TAG_DESC_PAIRS]


def _random_tags():
    return random.sample(_TAGS, random.randint(1, len(_TAGS)-1))


def text_to_bbcode(text, tags):
    while tags:
        text = '[{0}]{1}[/{0}]'.format(tags.pop(), text)
    return text


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='BBCode encode user input.')
    parser.add_argument('text', nargs='*', help='text to be encoded')
    for tag, desc in _TAG_DESC_PAIRS:
        parser.add_argument('-%s' % tag, action='append_const', dest='tags',
                            const=tag, help='insert %s tag' % desc)
    parser.add_argument('--faggot', action='store_true',
                        help="insert ``faggot'' quotes")
    parser.add_argument('--mode', choices=['all', 'random', 'ransom'],
                        help=('special modes for applying all tags to the '
                              'text, a random selection of tags to the text, '
                              'or a random selection of tags to each '
                              'character of the text.'))
    args = parser.parse_args()
    # Make sure 'code' comes last because tags inside it will not render.
    if args.tags and 'code' in args.tags:
        args.tags.append(args.tags.pop(args.tags.index('code')))
    text = ' '.join(args.text) or sys.stdin.read().strip()
    if args.faggot is True:
        text = "``%s''" % text
    if args.mode is None:
        print text_to_bbcode(text, args.tags)
    if args.mode == 'all':
        print text_to_bbcode(text, _TAGS)
    elif args.mode == 'random':
        print text_to_bbcode(text, _random_tags())
    elif args.mode == 'ransom':
        print ''.join(c if c.isspace() else text_to_bbcode(c, _random_tags()) for c in text)


If you decide to hack it, post the code here. Have fun.

Name: Anonymous 2011-08-10 0:56

You realize that it takes longer to type up the command line arguments than to write the BBCode myself, right?

Name: Anonymous 2011-08-10 1:01

>>2
You mean you can type

$ bb -boiu EXPERT PROGRAMMER | bb --faggot | bb -code
``[b][o][i][u]EXPERT PROGRAMMER[/u][/i][/o][/b]''

faster than you can type ``bb -boiu EXPERT PROGRAMMER''?

Impressive.

Name: Anonymous 2011-08-10 1:07

bb + figlet is fun.

$ figlet hello | bb -b -code
_          _ _      
| |__   ___| | | ___ 
| '_ \ / _ \ | |/ _ \
| | | |  __/ | | (_) |
|_| |_|\___|_|_|\___/

kc@ubuntu:/tmp$ figlet /prog/ | bb -b -code -spoiler
__                        __
   / / __  _ __ ___   __ _   / /
  / / '_ \| '__/ _ \ / _` | / /
 / /| |_) | | | (_) | (_| |/ / 
/_/ | .__/|_|  \___/ \__, /_/  
    |_|              |___/

Name: Anonymous 2011-08-10 3:30

/frog in August - Reddit fags discover BBCode

Name: Anonymous 2011-08-10 4:29

>>3
You forgot to take into consideration that most people do not BBCode their whole post, but often word by word with different tags. For example, BBCode. This would literally take me forever with your ``tool''.

Name: Anonymous 2011-08-10 4:40

>>4
Ubuntu

Name: Anonymous 2011-08-10 5:09

>>6
$ bb -spoiler you don\'t have to write `bb -i --faggot the whole thing` in `bb -biou ONE LINE`
you don't have to write ``the whole thing'' in ONE LINE
It's just for fun, lighten up.

>>7
$ (echo deal with it && bb --faggot faggot) | figlet -c | bb -m
                   _            _            _ _   _       _ _  
                __| | ___  __ _| | __      _(_) |_| |__   (_) |_
               / _` |/ _ \/ _` | | \ \ /\ / / | __| '_ \  | | __|
              | (_| |  __/ (_| | |  \ V  V /| | |_| | | | | | |_
               \__,_|\___|\__,_|_|   \_/\_/ |_|\__|_| |_| |_|\__|
                                                                
                    _ _  __                         _   _ _
                   ( | )/ _| __ _  __ _  __ _  ___ | |_( | )
                    \|\| |_ / _` |/ _` |/ _` |/ _ \| __|/|/
                       |  _| (_| | (_| | (_| | (_) | |_    
                       |_|  \__,_|\__, |\__, |\___/ \__|   
                                  |___/ |___/              

Name: Anonymous 2011-08-10 8:29

Because typing ``'' is so hard. I'm glad there is a --faggot option. Fits you.

Name: Anonymous 2011-08-10 12:08

You're so bitter, /prog/. I think it's a nice (if useless) initiative.

Name: Anonymous 2011-08-10 14:15

>>9
Whatevs. It was supposed to be an Easter egg but I couldn't find an option to hide it form the help menu. Either way, it makes more sense when working with the command line. Observe:

$ echo ``hello, world''
hello, world
$ echo "``"hello, world"''"
hello, world''
$ echo '``'hello, world"''"
``hello, world''
$ echo \`\`hello, world\'\'
``hello, world''


Anyways, here's 1.1 with even more useless features.

$ bb -h | bb -m
usage: bb [-h] [-v] [-b] [-i] [-o] [-u] [-s] [-m] [-spoiler] [-sub] [-sup]
          [-aa] [-code] [--faggot] [--cruise] [--rot13] [--omg-optimized]
          [--mode {all,random,ransom}]
          [text [text ...]]

BBCode encode user input.

positional arguments:
  text                  text to be encoded

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -b                    insert bold tag
  -i                    insert italics tag
  -o                    insert overline tag
  -u                    insert underline tag
  -s                    insert strikethrough tag
  -m                    insert monospace tag
  -spoiler              insert spoiler tag
  -sub                  insert subscript tag
  -sup                  insert superscript tag
  -aa                   insert Shift JIS tag
  -code                 insert code tag
  --faggot              insert ``faggot'' quotes
  --cruise              CRUISE CONTROL
  --rot13               awesoma powa!
  --omg-optimized       VROOM VROOM!
  --mode {all,random,ransom}
                        special modes for applying all tags to the text, a
                        random selection of tags to the text, or a random
                        selection of tags to each character of the text.


$ cat ~/bin/bb | bb -code
#!/usr/bin/env python

import argparse
import logging
import random
import sys


_MAX_CHARS = 10000


_TAG_DESC_PAIRS = [
        ('b', 'bold'), ('i', 'italics'), ('o', 'overline'), ('u', 'underline'),
        ('s', 'strikethrough'), ('m', 'monospace'), ('spoiler', 'spoiler'),
        ('sub', 'subscript'), ('sup', 'superscript'), ('aa', 'Shift JIS'),
        ('code', 'code')]


_TAGS = [tag for tag, desc in _TAG_DESC_PAIRS]


def _random_tags(min=2, max=len(_TAGS)-1):
    return random.sample(_TAGS, random.randint(min, max))


def _optimize(text):
    return ('#include <stdio.h>\nint main () {\n\tputs("%s");\n\treturn 0;\n }'
            % text.replace('\n', '\\n'))


def text_to_bbcode(text, tags):
    while tags:
        text = '[{0}]{1}[/{0}]'.format(tags.pop(), text)
    return text


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='BBCode encode user input.')
    parser.add_argument('text', nargs='*', help='text to be encoded')
    parser.add_argument('-v', '--version', action='version',
                        version='%(prog)s 1.1')
    for tag, desc in _TAG_DESC_PAIRS:
        parser.add_argument('-%s' % tag, action='append_const', dest='tags',
                            const=tag, help='insert %s tag' % desc)
    parser.add_argument('--faggot', action='store_true',
                        help="insert ``faggot'' quotes")
    parser.add_argument('--cruise', action='store_true',
                        help='CRUISE CONTROL')
    parser.add_argument('--rot13', action='store_true',
                        help='awesoma powa!')
    parser.add_argument('--omg-optimized', action='store_true',
                        help='VROOM VROOM!')
    parser.add_argument('--mode', choices=['all', 'random', 'ransom'],
                        help=('special modes for applying all tags to the '
                              'text, a random selection of tags to the text, '
                              'or a random selection of tags to each '
                              'character of the text.'))
    args = parser.parse_args()
    # Make sure 'code' comes last because tags inside it will not render.
    if args.tags and 'code' in args.tags:
        args.tags.append(args.tags.pop(args.tags.index('code')))
    text = ' '.join(args.text) or sys.stdin.read().rstrip('\n')
    if args.rot13 is True:
        text = text.encode('rot13')
    if args.cruise is True:
        text = text.upper()
    if args.faggot is True:
        text = "``%s''" % text
    if args.mode is None:
        text = text_to_bbcode(text, args.tags)
    elif args.mode == 'all':
        text = text_to_bbcode(text, _TAGS)
    elif args.mode == 'random':
        text = text_to_bbcode(text, _random_tags())
    elif args.mode == 'ransom':
        text = ''.join(c if c.isspace() else text_to_bbcode(c, _random_tags())
                       for c in text)
    if args.omg_optimized is True:
        text = _optimize(text)
    print text
    if len(text) > _MAX_CHARS:
        logging.warning("it's over %d (too big for Shiichan)", _MAX_CHARS)

Name: Anonymous 2011-08-11 15:57

$ ./sex.py
Greetings {spoiler /prog/} from an {b.i.o.u EXPERT {sup B{sup B{sup C{sub O{sub D{sub E}}}}}} PROGRAMMER !!}
Since you can't into Unix, I wrote you a S{sub e}x{sup p}C{sub o}d{sup e} interpreter.
It's doesn't support things like \{sup*3 this\} because I didn't feel like it.
That is left as an exercise for the hacker on ``her'' way to becoming a {b.i.o.u ``SEXPERT'' PROGRAMMER}.
{i Have fun !!}

Greetings /prog/ from an EXPERT BBCODE PROGRAMMER !!
Since you can't into Unix, I wrote you a SexpCode interpreter.
It's doesn't support things like {sup*3 this} because I didn't feel like it.
That is left as an exercise for the hacker on ``her'' way to becoming a ``SEXPERT'' PROGRAMMER.
Have fun !!

$ cat sex.py | bb -code
#!/usr/bin/env python

import sys


def eval_(exp):
    words = exp[1:-1].split(' ')
    tags = words.pop(0).split('.')
    output = parse(' '.join(words))
    while tags:
        output = '[{0}]{1}[/{0}]'.format(tags.pop(0), output)
    return output


def parse(exp):
    start = None
    depth = 0
    output = str(exp)
    for i, c in enumerate(exp):
        if c == '{' and (i == 0 or exp[i-1] != '\\'):
            if start is None:
                start = i
            else:
                depth += 1
        elif c == '}':
            if depth == 0:
                old = exp[start:i+1]
                new = eval_(old)
                output = output.replace(old, new)
                start = None
            else:
                depth -= 1
    return output.replace('\{', '{').replace('\}', '}')


if __name__ == '__main__':
    text = ' '.join(sys.argv[1:]) or sys.stdin.read()
    print parse(text)

Name: Anonymous 2011-08-11 16:35

This thread reeks of FIOC, IHBT!!!

Name: Anonymous 2011-08-11 16:47

>>13
Yeah I couldn't help but notice that even though /prog/ will cry ``FIOC'' and attack it every chance it gets, 99% of the complete working programs posted here are written in Python. Either Lisp is shit or Listhpers can't program. Likely both.

Name: Anonymous 2011-08-11 16:58

Name: Anonymous 2011-08-11 18:23

>>14
Lisp is ugly, but not terrible. I do agree with your latter point. All of the current batch of ``Listhpers" on here can't do shit. They are those people who see Lisp and instantly think of it as a divine silver bullet without considering its drawbacks. Fucking hate them.

Name: Anonymous 2011-08-11 18:30

>>10
What is nice about it, ``faggot''?

Name: Anonymous 2011-08-11 20:41

>>17
It makes you buttfrustrated, that's nice enough.

Name: Anonymous 2011-08-11 20:48

>>18
Still trying too hard.

Name: Anonymous 2011-11-29 23:35

Fuck yeah, Googled ``console BB code generator'' and found this. Thank you Anonymous.

Name: Anonymous 2012-01-13 2:09

A fatal error occured!
That password is wrong!

Name: Anonymous 2012-01-13 5:41

You know that you're using is incorrectly, right?

Name: Anonymous 2012-01-13 6:23

>>22
Comparisons to singletons like None should always be done with 'is' or 'is not', never the equality operators.
Where ITT is it being used incorrectly?

Name: Anonymous 2012-01-13 6:24

Name: Anonymous 2012-01-13 11:45

Although this thread is OLD AS FUCK, >>16 is correct. There are probably 1-2 experienced Lispers on this board. The rest are probably incompetent and/or learning.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-13 12:00

>>1
That shit's uglier than your mom. Wouldn't it just be easier, quicker, and for more robust to emulate a case/switch inside a single iterator?

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-13 12:03

>>26
The way I see it is that it would then become a nobrainer to pass multiple commands in a single bound.

Name: Anonymous 2012-01-13 12:53

>>26
Kodak, why did you have to make fun of the guys mother? That's below the belt man, you don't do that.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-13 12:56

>>28
But calling someone a jew is okay? Anyways, I was hoping the computer science major who can't seem to get a job would have posted at least completed one of the exercises in this thread. Ya know, at least show us that he/she/it can do more than google shit.

Name: Anonymous 2012-01-13 12:59

>>29
Well, if you're doing it directly to him I think it's okay to call him a Jew, but I don't think it's right to attack his family members. For all we know his mother is a great programmer and his father is a mental midget so he came out a mental midget as well, it's not his mothers fault.

Name: Anonymous 2012-01-13 16:29

>>1
cat ~/bin/bb | bb -code
cat abuse
bb -code < ~/bin/bb

Name: Anonymous 2012-01-13 16:48

>>31
That's a new level of autism right there.

>>33
Nice dubs.

Name: Anonymous 2012-01-13 16:48

>>32
Thank you kindly, bro.

Name: Anonymous 2012-06-06 5:22

>>6
literally
NOPE!

Name: Anonymous 2012-06-06 5:39

Kodak the toilet scrubber - AHAHAHAHAHAAHAHAHAHAHAAHAHAH!

He's one of those naked clothesline-swinging gallery programmers.

Name: Anonymous 2012-06-06 5:40

bump my anii

Name: Anonymous 2012-06-06 5:45

TERRIBLE!

Name: Anonymous 2012-06-06 10:02

>>8
using
a cl bb code generator lol

h
o w p a t h e t i c a r e y o u ? ? ? ?

h
o w p a t h e t i c a r e y o u ? ? ? ?

h
o w p a t h e t i c a r e y o u ? ? ? ?
h
o w p a t h e t i c a r e y o u ? ? ? ?

h
o w p a t h e t i c a r e y o u ? ? ? ?

Name: Anonymous 2012-06-06 15:36

That's great that you've written a BB code generating program, OP, but I've written a BB code generating program generating program:
#include <stdio.h>

int main(void)
{
    puts("#!/usr/bin/env python\n\nimport argparse\nimport random\nimport sys\n\n\n_TAG_DESC_PAIRS = [\n\t\t('b', 'bold'), ('i', 'italics'), ('o', 'overline'), ('u', 'underline'),\n\t\t('s', 'strikethrough'), ('m', 'monospace'), ('spoiler', 'spoiler'),\n\t\t('sub', 'subscript'), ('sup', 'superscript'), ('aa', 'Shift JIS'),\n\t\t('code', 'code')]\n\n\n_TAGS = [tag for tag, desc in _TAG_DESC_PAIRS]\n\n\ndef _random_tags():\n\treturn random.sample(_TAGS, random.randint(1, len(_TAGS)-1))\n\n\ndef text_to_bbcode(text, tags):\n\twhile tags:\n\t\ttext = '[{0}]{1}[/{0}]'.format(tags.pop(), text)\n\treturn text\n\n\nif __name__ == '__main__':\n\tparser = argparse.ArgumentParser(description='BBCode encode user input.')\n\tparser.add_argument('text', nargs='*', help='text to be encoded')\n\tfor tag, desc in _TAG_DESC_PAIRS:\n\t\tparser.add_argument('-%s' % tag, action='append_const', dest='tags',\n\t\t\t\t\t\t\tconst=tag, help='insert %s tag' % desc)\n\tparser.add_argument('--faggot', action='store_true',\n\t\t\t\t\t\thelp='insert ``faggot'' quotes')\n\tparser.add_argument('--mode', choices=['all', 'random', 'ransom'],\n\t\t\t\t\t\thelp=('special modes for applying all tags to the '\n\t\t\t\t\t\t\t 'text, a random selection of tags to the text, '\n\t\t\t\t\t\t\t 'or a random selection of tags to each '\n\t\t\t\t\t\t\t 'character of the text.'))\n\targs = parser.parse_args()\n\t# Make sure 'code' comes last because tags inside it will not render.\n\tif args.tags and 'code' in args.tags:\n\t\targs.tags.append(args.tags.pop(args.tags.index('code')))\n\ttext = ' '.join(args.text) or sys.stdin.read().strip()\n\tif args.faggot is True:\n\t\ttext = '``%s''' % text\n\tif args.mode is None:\n\t\tprint text_to_bbcode(text, args.tags)\n\tif args.mode == 'all':\n\t\tprint text_to_bbcode(text, _TAGS)\n\telif args.mode == 'random':\n\t\tprint text_to_bbcode(text, _random_tags())\n\telif args.mode == 'ransom':\n\t\tprint ''.join(c if c.isspace() else text_to_bbcode(c, _random_tags()) for c in text)");
    return 0;
}

Consider yourself one-upped.

Name: Anonymous 2012-06-06 15:42

puts("#!/usr/bin/env python\n\nimport argparse\nimport random\nimport sys\n\n\n_TAG_DESC_PAIRS = [\n\t\t('b', 'bold'), ('i', 'italics'), ('o', 'overline'), ('u', 'underline'),\n\t\t('s', 'strikethrough'), ('m', 'monospace'), ('spoiler', 'spoiler'),\n\t\t('sub', 'subscript'), ('sup', 'superscript'), ('aa', 'Shift JIS'),\n\t\t('code', 'code')]\n\n\n_TAGS = [tag for tag, desc in _TAG_DESC_PAIRS]\n\n\ndef _random_tags():\n\treturn random.sample(_TAGS, random.randint(1, len(_TAGS)-1))\n\n\ndef text_to_bbcode(text, tags):\n\twhile tags:\n\t\ttext = '[{0}]{1}[/{0}]'.format(tags.pop(), text)\n\treturn text\n\n\nif __name__ == '__main__':\n\tparser = argparse.ArgumentParser(description='BBCode encode user input.')\n\tparser.add_argument('text', nargs='*', help='text to be encoded')\n\tfor tag, desc in _TAG_DESC_PAIRS:\n\t\tparser.add_argument('-%s' % tag, action='append_const', dest='tags',\n\t\t\t\t\t\t\tconst=tag, help='insert %s tag' % desc)\n\tparser.add_argument('--faggot', action='store_true',\n\t\t\t\t\t\thelp='insert ``faggot'' quotes')\n\tparser.add_argument('--mode', choices=['all', 'random', 'ransom'],\n\t\t\t\t\t\thelp=('special modes for applying all tags to the '\n\t\t\t\t\t\t\t 'text, a random selection of tags to the text, '\n\t\t\t\t\t\t\t 'or a random selection of tags to each '\n\t\t\t\t\t\t\t 'character of the text.'))\n\targs = parser.parse_args()\n\t# Make sure 'code' comes last because tags inside it will not render.\n\tif args.tags and 'code' in args.tags:\n\t\targs

Name: Anonymous 2012-06-06 15:42

puts("#!/usr/bin/env python\n\nimport argparse\nimport random\nimport sys\n\n\n_TAG_DESC_PAIRS = [\n\t\t('b', 'bold'), ('i', 'italics'), ('o', 'overline'), ('u', 'underline'),\n\t\t('s', 'strikethrough'), ('m', 'monospace'), ('spoiler', 'spoiler'),\n\t\t('sub', 'subscript'), ('sup', 'superscript'), ('aa', 'Shift JIS'),\n\t\t('code', 'code')]\n\n\n_TAGS = [tag for tag, desc in _TAG_DESC_PAIRS]\n\n\ndef _random_tags():\n\treturn random.sample(_TAGS, random.randint(1, len(_TAGS)-1))\n\n\ndef text_to_bbcode(text, tags):\n\twhile tags:\n\t\ttext = '[{0}]{1}[/{0}]'.format(tags.pop(), text)\n\treturn text\n\n\nif __name__ == '__main__':\n\tparser = argparse.ArgumentParser(description='BBCode encode user input.')\n\tparser.add_argument('text', nargs='*', help='text to be encoded')\n\tfor tag, desc in _TAG_DESC_PAIRS:\n\t\tparser.add_argument('-%s' % tag, action='append_const', dest='tags',\n\t\t\t\t\t\t\tconst=tag, help='insert %s tag' % desc)\n\tparser.add_argument('--faggot', action='store_true',\n\t\t\t\t\t\thelp='insert ``faggot'' quotes')\n\tparser.add_argument('--mode', choices=['all', 'random', 'ransom'],\n\t\t\t\t\t\thelp=('special modes for applying all tags to the '\n\t\t\t\t\t\t\t 'text, a random selection of tags to the text, '\n\t\t\t\t\t\t\t 'or a random selection of tags to each '\n\t\t\t\t\t\t\t 'character of the text.'))\n\targs = parser.parse_args()\n\t# Make sure 'code' comes last because tags inside it will not render.\n\tif args.tags and 'code' in args.tags:\n\t\targs

Name: Anonymous 2012-06-06 15:42

puts("#!/usr/bin/env python\n\nimport argparse\nimport random\nimport sys\n\n\n_TAG_DESC_PAIRS = [\n\t\t('b', 'bold'), ('i', 'italics'), ('o', 'overline'), ('u', 'underline'),\n\t\t('s', 'strikethrough'), ('m', 'monospace'), ('spoiler', 'spoiler'),\n\t\t('sub', 'subscript'), ('sup', 'superscript'), ('aa', 'Shift JIS'),\n\t\t('code', 'code')]\n\n\n_TAGS = [tag for tag, desc in _TAG_DESC_PAIRS]\n\n\ndef _random_tags():\n\treturn random.sample(_TAGS, random.randint(1, len(_TAGS)-1))\n\n\ndef text_to_bbcode(text, tags):\n\twhile tags:\n\t\ttext = '[{0}]{1}[/{0}]'.format(tags.pop(), text)\n\treturn text\n\n\nif __name__ == '__main__':\n\tparser = argparse.ArgumentParser(description='BBCode encode user input.')\n\tparser.add_argument('text', nargs='*', help='text to be encoded')\n\tfor tag, desc in _TAG_DESC_PAIRS:\n\t\tparser.add_argument('-%s' % tag, action='append_const', dest='tags',\n\t\t\t\t\t\t\tconst=tag, help='insert %s tag' % desc)\n\tparser.add_argument('--faggot', action='store_true',\n\t\t\t\t\t\thelp='insert ``faggot'' quotes')\n\tparser.add_argument('--mode', choices=['all', 'random', 'ransom'],\n\t\t\t\t\t\thelp=('special modes for applying all tags to the '\n\t\t\t\t\t\t\t 'text, a random selection of tags to the text, '\n\t\t\t\t\t\t\t 'or a random selection of tags to each '\n\t\t\t\t\t\t\t 'character of the text.'))\n\targs = parser.parse_args()\n\t# Make sure 'code' comes last because tags inside it will not render.\n\tif args.tags and 'code' in args.tags:\n\t\targs

Name: Anonymous 2012-06-06 15:43

puts("#!/usr/bin/env python\n\nimport argparse\nimport random\nimport sys\n\n\n_TAG_DESC_PAIRS = [\n\t\t('b', 'bold'), ('i', 'italics'), ('o', 'overline'), ('u', 'underline'),\n\t\t('s', 'strikethrough'), ('m', 'monospace'), ('spoiler', 'spoiler'),\n\t\t('sub', 'subscript'), ('sup', 'superscript'), ('aa', 'Shift JIS'),\n\t\t('code', 'code')]\n\n\n_TAGS = [tag for tag, desc in _TAG_DESC_PAIRS]\n\n\ndef _random_tags():\n\treturn random.sample(_TAGS, random.randint(1, len(_TAGS)-1))\n\n\ndef text_to_bbcode(text, tags):\n\twhile tags:\n\t\ttext = '[{0}]{1}[/{0}]'.format(tags.pop(), text)\n\treturn text\n\n\nif __name__ == '__main__':\n\tparser = argparse.ArgumentParser(description='BBCode encode user input.')\n\tparser.add_argument('text', nargs='*', help='text to be encoded')\n\tfor tag, desc in _TAG_DESC_PAIRS:\n\t\tparser.add_argument('-%s' % tag, action='append_const', dest='tags',\n\t\t\t\t\t\t\tconst=tag, help='insert %s tag' % desc)\n\tparser.add_argument('--faggot', action='store_true',\n\t\t\t\t\t\thelp='insert ``faggot'' quotes')\n\tparser.add_argument('--mode', choices=['all', 'random', 'ransom'],\n\t\t\t\t\t\thelp=('special modes for applying all tags to the '\n\t\t\t\t\t\t\t 'text, a random selection of tags to the text, '\n\t\t\t\t\t\t\t 'or a random selection of tags to each '\n\t\t\t\t\t\t\t 'character of the text.'))\n\targs = parser.parse_args()\n\t# Make sure 'code' comes last because tags inside it will not render.\n\tif args.tags and 'code' in args.tags:\n\t\targs

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