def bbcode(string):
    markup = postmarkup.PostMarkup()

    markup.add_tag(postmarkup.SimpleTag, 'b', 'strong')
    markup.add_tag(postmarkup.SimpleTag, 'i', 'em')
    markup.add_tag(postmarkup.SimpleTag, 'u', 'u')
    markup.add_tag(postmarkup.SimpleTag, 's', 's')

    return markup.render_to_html(string)
示例#2
0
def customize_postmarkup(allow_external_links):
    custom_postmarkup = postmarkup.PostMarkup()
    add_tag = custom_postmarkup.tag_factory.add_tag
    custom_postmarkup.tag_factory.set_default_tag(postmarkup.DefaultTag)

    add_tag(CSSClassTag, 'b', 'bb-bold')
    add_tag(CSSClassTag, 'i', 'bb-italic')
    add_tag(CSSClassTag, 'u', 'bb-underline')
    add_tag(CSSClassTag, 's', 'bb-strikethrough')

    add_tag(ScratchblocksTag, 'scratchblocks')

    add_tag(FilteredLinkTag if allow_external_links else RestrictedLinkTag,
            'url')

    add_tag(QuoteTag, 'quote')

    add_tag(postmarkup.SearchTag, u'wp',
            u"http://en.wikipedia.org/wiki/Special:Search?search=%s",
            u'wikipedia.com', None)
    add_tag(postmarkup.SearchTag, u'wiki',
            u"http://wiki.scratch.mit.edu/wiki/Special:Search?search=%s",
            u'wiki.scratch.mit.edu', None)
    add_tag(postmarkup.SearchTag, u'google',
            u"http://www.google.com/search?hl=en&q=%s&btnG=Google+Search",
            u'google.com', None)
    add_tag(postmarkup.SearchTag, u'dictionary',
            u"http://dictionary.reference.com/browse/%s", u'dictionary.com',
            None)
    add_tag(postmarkup.SearchTag, u'dict',
            u"http://dictionary.reference.com/browse/%s", u'dictionary.com',
            None)

    add_tag(WhitelistedImgTag, u'img')
    add_tag(postmarkup.ListTag, u'list')
    add_tag(postmarkup.ListItemTag, u'*')

    # removed 'size' and replaced it with 'big' and 'small'
    add_tag(CSSClassTag, u'big', u'bb-big')
    add_tag(CSSClassTag, u'small', u'bb-small')
    add_tag(postmarkup.ColorTag, u"color")
    add_tag(postmarkup.CenterTag, u"center")
    add_tag(postmarkup.PygmentsCodeTag, u'code', None)

    add_tag(postmarkup.SimpleTag, u"p", 'p')

    return custom_postmarkup
示例#3
0
def customize_postmarkup():
    custom_postmarkup = postmarkup.PostMarkup()
    add_tag = custom_postmarkup.tag_factory.add_tag
    custom_postmarkup.tag_factory.set_default_tag(postmarkup.DefaultTag)

    add_tag(postmarkup.SimpleTag, 'b', 'strong')
    add_tag(postmarkup.SimpleTag, 'i', 'em')
    add_tag(postmarkup.SimpleTag, 'u', 'u')
    add_tag(postmarkup.SimpleTag, 's', 'strike')

    add_tag(postmarkup.LinkTag, 'link', None)
    add_tag(postmarkup.LinkTag, 'url', None)

    add_tag(postmarkup.QuoteTag, 'quote')

    add_tag(postmarkup.SearchTag, u'wiki',
            u"http://en.wikipedia.org/wiki/Special:Search?search=%s",
            u'wikipedia.com', None)
    add_tag(postmarkup.SearchTag, u'google',
            u"http://www.google.com/search?hl=en&q=%s&btnG=Google+Search",
            u'google.com', None)
    add_tag(postmarkup.SearchTag, u'dictionary',
            u"http://dictionary.reference.com/browse/%s", u'dictionary.com',
            None)
    add_tag(postmarkup.SearchTag, u'dict',
            u"http://dictionary.reference.com/browse/%s", u'dictionary.com',
            None)

    add_tag(postmarkup.ImgTag, u'img')
    add_tag(postmarkup.ListTag, u'list')
    add_tag(postmarkup.ListItemTag, u'*')

    # removed 'size' and replaced it with 'big' and 'small'
    add_tag(postmarkup.SimpleTag, 'big', 'span style="font-size:32px"')
    add_tag(postmarkup.SimpleTag, 'small', 'span style="font-size:10px"')
    add_tag(postmarkup.ColorTag, u"color")
    add_tag(postmarkup.CenterTag, u"center")
    add_tag(postmarkup.PygmentsCodeTag, u'code', None)

    add_tag(postmarkup.SimpleTag, u"p", 'p')

    return custom_postmarkup
示例#4
0
                ret['nextshow'] = {'name': nextshow.name,
                                   'begin': int(to_user_timezone(nextshow.begin).strftime("%s")) * 1000,
                                   'logo': nextshow.get_logo()}
                if nextshow.series:
                    ret['nextshow']['series'] = nextshow.series.name
        return jsonify({'success': True, 'data': ret})
    except Exception as e:
        raise e
        return jsonify({'success': False, 'data': unicode(e)})


def menu():
    return request.menu


markup = postmarkup.PostMarkup()
markup.default_tags()


# Jinja2 filter: bbcode
def bbcode(value):
    return markup.render_to_html(value)

# Jinja2 filter: timedelta
def timedelta(value):
    days = value.days
    hours, remainder = divmod(value.seconds, 3600)
    minutes, seconds = divmod(remainder, 60)
    return u"{days} Days, {hours} Hours, {minutes} Minutes and {seconds} Seconds".format(days=days,
                                                                                         hours=hours,
                                                                                         minutes=minutes,
示例#5
0
def bbcode(value):
    markup = postmarkup.PostMarkup()
    markup.default_tags()
    return markup.render_to_html(value)