Esempio n. 1
0
def jsonml(l):
    node = '<' + l[0]
    i = 1
    if isinstance(l[1], dict):
        i = 2
        for k, v in l[1].items():
            node += ' ' + k + '="' + text_type(escape(v)) + '"'
    node += '>'
    for c in l[i:]:
        if isinstance(c, list):
            node += text_type(jsonml(c))
        else:
            node += text_type(escape(c))
    node += '</' + l[0] + '>'
    return Markup(node)
Esempio n. 2
0
def linebreaksbr(text):
    """Convert all newlines ("\n") in a string to HTML line breaks ("<br />")"""
    is_markup = isinstance(text, Markup)
    text = normalize_newlines(text)
    if not is_markup:
        text = text_type(jinja2.escape(text))
    text = text.replace('\n', '<br />')
    return safe_string(text)
Esempio n. 3
0
def linebreaksbr(text):
    """Convert all newlines ("\n") in a string to HTML line breaks ("<br />")"""
    is_markup = isinstance(text, Markup)
    text = normalize_newlines(text)
    if not is_markup:
        text = text_type(jinja2.escape(text))
    text = text.replace('\n', '<br />')
    return safe_string(text)
Esempio n. 4
0
 def get_body(self, environ=None):
     """Get the HTML body."""
     return text_type(
         (u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n'
          u"<title>%(code)s %(name)s</title>\n"
          u"<h1>%(name)s</h1>\n"
          u"%(description)s\n") % {
              "code": self.code,
              "name": self.name,
              "description": self.get_description(environ),
          })
Esempio n. 5
0
def markdown_escape(s):
    """Convert the characters &, <, >, ' and " in string s to HTML-safe
    sequences.  Use this if you need to display text that might contain
    such characters in HTML.  Marks return value as markup string.
    """
    if hasattr(s, "__html__"):
        return s.__html__().replace("&gt;", ">")
    return Markup(
        text_type(s)
        .replace("&", "&amp;")
        .replace(">", "&gt;")
        .replace("<", "&lt;")
        .replace("'", "&#39;")
        .replace('"', "&#34;")
    )
Esempio n. 6
0
def markdown_escape(s):
    """Convert the characters &, <, >, ' and " in string s to HTML-safe
    sequences.  Use this if you need to display text that might contain
    such characters in HTML.  Marks return value as markup string.
    """
    if hasattr(s, '__html__'):
        return s.__html__().replace('&gt;', '>')
    return Markup(
        text_type(s).replace('&', '&amp;').replace('>', '&gt;').replace(
            '<', '&lt;').replace("'", '&#39;').replace('"', '&#34;'))


#@blueprint.route('/f/ulastpost')
#def ulastpost():
#    topics = Topic.objects()
#    for topic in topics:
#        post = Post.objects(topic=topic).order_by('-date').first()
#        topic.last_post_date = post.date
#        topic.save()
#    return 'ye'