Пример #1
0
def render_bbcode(value):
    """
    Generates (X)HTML from string with BBCode "markup".
    By using the postmark lib from:
    @see: http://code.google.com/p/postmarkup/

    """
    value = mark_safe(_render_bbcode(value).replace("[", "[").replace("]", "]"))
    return value
Пример #2
0
def render_bbcode(value, nbsp=False):
    """
    Generates (X)HTML from string with BBCode "markup".
    By using the postmark lib from:
    @see: http://code.google.com/p/postmarkup/

    """
    value = _render_bbcode(value)\
        .replace('[', '[').replace(']', ']')
    if nbsp:
        value = re.sub('(^|<[^/>][^>]+>)(\s+)', lambda r: r.group(1) + '&nbsp;' * len(r.group(2)), value)
    return mark_safe(value)