blog/app/util/__init__.py
def fancy_html(s, apply_p_blocks=True):
    """ Accepts a string; returns fancy-ass HTML with all of our cool stuff."""

    s = str(s)
    if apply_p_blocks:
        raw = "".join(["<p>%s</p>" % p for p in s.split('\n') if p != ''])
    else:
        raw = str(s)

    # expand links -- do this before we get to HTML junk
    raw_list = raw.split(" ")
    for word in raw_list:
        if word[:8] == 'https://':
            index = raw_list.index(word)
            url = word
            if url[-1] in [',','.']:
                url = url[:-1]
            raw_list[index] = '<a href="%s">%s</a>' % (url,word)
    raw = " ".join(raw_list)

    soup = BeautifulSoup(raw, 'html.parser')

    # fix anchors
    for anchor in soup.find_all('a'):
        if 'fancy' not in anchor.get('class', []):
            anchor['class'] = anchor.get('class', []) + ['fancy']

        anchor['target'] = 'top'

    return str(soup)
 Accepts a string; returns fancy-ass HTML with all of our cool stuff.
Accepts a string; returns fancy-ass HTML with all of our cool stuff.
Accepts a string ; returns fancy - ass HTML with all of our cool stuff .
def fancy_html(s, apply_p_blocks=True):
    s = str(s)
    if apply_p_blocks:
        raw = "".join(["<p>%s</p>" % p for p in s.split('\n') if p != ''])
    else:
        raw = str(s)
    raw_list = raw.split(" ")
    for word in raw_list:
        if word[:8] == 'https://':
            index = raw_list.index(word)
            url = word
            if url[-1] in [',','.']:
                url = url[:-1]
            raw_list[index] = '<a href="%s">%s</a>' % (url,word)
    raw = " ".join(raw_list)
    soup = BeautifulSoup(raw, 'html.parser')
    for anchor in soup.find_all('a'):
        if 'fancy' not in anchor.get('class', []):
            anchor['class'] = anchor.get('class', []) + ['fancy']
        anchor['target'] = 'top'
    return str(soup)
def fancy_html ( s , apply_p_blocks = True ) : s = str ( s ) if apply_p_blocks : raw = "" . join ( [ "<p>%s</p>" % p for p in s . split ( '\n' ) if p != '' ] ) else : raw = str ( s ) raw_list = raw . split ( " " ) for word in raw_list : if word [ : 8 ] == 'https://' : index = raw_list . index ( word ) url = word if url [ - 1 ] in [ ',' , '.' ] : url = url [ : - 1 ] raw_list [ index ] = '<a href="%s">%s</a>' % ( url , word ) raw = " " . join ( raw_list ) soup = BeautifulSoup ( raw , 'html.parser' ) for anchor in soup . find_all ( 'a' ) : if 'fancy' not in anchor . get ( 'class' , [ ] ) : anchor [ 'class' ] = anchor . get ( 'class' , [ ] ) + [ 'fancy' ] anchor [ 'target' ] = 'top' return str ( soup )
Accepts a string; returns fancy-ass HTML with all of our cool stuff.
Accepts a string ; returns fancy - ass HTML with all of our cool stuff .
""" Accepts a string; returns fancy-ass HTML with all of our cool stuff.""" # expand links -- do this before we get to HTML junk # fix anchors
s
apply_p_blocks