How to use the markupsafe.Markup function in MarkupSafe

To help you get started, we’ve selected a few MarkupSafe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libfirm / libfirm / scripts / markupsafe / tests.py View on Github external
def test_splitting(self):
        self.assertEqual(Markup('a b').split(), [
            Markup('a'),
            Markup('b')
        ])
        self.assertEqual(Markup('a b').rsplit(), [
            Markup('a'),
            Markup('b')
        ])
        self.assertEqual(Markup('a\nb').splitlines(), [
            Markup('a'),
            Markup('b')
        ])
github rethinkdb / rethinkdb / test / common / http_support / markupsafe / tests.py View on Github external
def test_splitting(self):
        self.assertEqual(Markup('a b').split(), [
            Markup('a'),
            Markup('b')
        ])
        self.assertEqual(Markup('a b').rsplit(), [
            Markup('a'),
            Markup('b')
        ])
        self.assertEqual(Markup('a\nb').splitlines(), [
            Markup('a'),
            Markup('b')
        ])
github libfirm / libfirm / scripts / markupsafe / tests.py View on Github external
def test_formatting(self):
        for actual, expected in (
            (Markup('%i') % 3.14, '3'),
            (Markup('%.2f') % 3.14159, '3.14'),
            (Markup('%s %s %s') % ('<', 123, '>'), '< 123 >'),
            (Markup('<em>{awesome}</em>').format(awesome=''),
             '<em>&lt;awesome&gt;</em>'),
            (Markup('{0[1][bar]}').format([0, {'bar': ''}]),
             '&lt;bar/&gt;'),
            (Markup('{0[1][bar]}').format([0, {'bar': Markup('')}]),
             '')):
            assert actual == expected, "%r should be %r!" % (actual, expected)
github NetEase / airtest / airtest / log2html.py View on Github external
# Read log line by line
    from . import proto
    records = []
    for line in open(logfile):
        v = json.loads(line)
        r = {'time': time.strftime(TIME_FORMAT, time.localtime(v.get('timestamp')))}
        d = v.get('data', {})
        tag = v.get('tag')

        # Process Function, Snapshot, Memory, CPU ...
        if tag == proto.TAG_FUNCTION:
            tag = markupsafe.Markup('function')    
            args = map(json.dumps, d.get('args'))
            kwargs = [ '%s=%s' %(k, json.dumps(_v)) for k, _v in d.get('kwargs', {}).items() ]
            message = '<code style="color:green">%s(%s)</code>' %(d.get('name'), ', '.join(args+kwargs))
            message = markupsafe.Markup(message)
        elif tag == proto.TAG_SNAPSHOT:
            message = markupsafe.Markup("<img src="%s" width="100%%">" % d.get('filename'))
        elif tag == proto.TAG_CPU:
            message = '%d%%' %(d)
            cpus.append([r, d])
        elif tag == proto.TAG_MEMORY:
            mems.append([r, d['PSS']])
            message = json.dumps(d)
        else:
            message = None
        
        if message:
            r['tag'] = tag
            r['message'] = message
            records.append(r)
github splunk / splunk-ref-pas-test / pas_simulated_users_addon / user-api / lib / markupsafe / tests.py View on Github external
def test_formatting(self):
        for actual, expected in (
            (Markup('%i') % 3.14, '3'),
            (Markup('%.2f') % 3.14159, '3.14'),
            (Markup('%s %s %s') % ('&lt;', 123, '&gt;'), '&lt; 123 &gt;'),
            (Markup('<em>{awesome}</em>').format(awesome=''),
             '<em>&lt;awesome&gt;</em>'),
            (Markup('{0[1][bar]}').format([0, {'bar': ''}]),
             '&lt;bar/&gt;'),
            (Markup('{0[1][bar]}').format([0, {'bar': Markup('')}]),
             '')):
            assert actual == expected, "%r should be %r!" % (actual, expected)
github libfirm / libfirm / scripts / markupsafe / tests.py View on Github external
def test_formatting(self):
        for actual, expected in (
            (Markup('%i') % 3.14, '3'),
            (Markup('%.2f') % 3.14159, '3.14'),
            (Markup('%s %s %s') % ('&lt;', 123, '&gt;'), '&lt; 123 &gt;'),
            (Markup('<em>{awesome}</em>').format(awesome=''),
             '<em>&lt;awesome&gt;</em>'),
            (Markup('{0[1][bar]}').format([0, {'bar': ''}]),
             '&lt;bar/&gt;'),
            (Markup('{0[1][bar]}').format([0, {'bar': Markup('')}]),
             '')):
            assert actual == expected, "%r should be %r!" % (actual, expected)
github toscawidgets / tw2.core / tw2 / core / templating.py View on Github external
        return lambda kwargs: Markup(
            ''.join(tmpl.generate(**kwargs).serialize('xhtml'))
        )
github idank / explainshell / explainshell / web / views.py View on Github external
break
        relativestart = start - m.start
        relativeend = end - m.start

        if i &lt; relativestart:
            for j in range(i, relativestart):
                if m.match[j].isspace():
                    expandedmatch += markupsafe.Markup('&nbsp;')
                else:
                    expandedmatch += markupsafe.escape(m.match[j])
            i = relativestart + 1
        if m.start &lt;= start and end &lt;= m.end:
            s = m.match[relativestart:relativeend]

            if kind == 'substitution':
                content = markupsafe.Markup(_substitutionmarkup(s))
            else:
                content = s

            expandedmatch += markupsafe.Markup(
                    '<span class="expansion-{0}">{1}</span>').format(kind, content)
            i = relativeend

    if i &lt; len(m.match):
        expandedmatch += markupsafe.escape(m.match[i:])

    assert expandedmatch
    d['match'] = expandedmatch
github clld / clld / clld / web / util / downloadwidget.py View on Github external
def js(self):
        return Markup(HTML.script(literal("""\
    $(document).ready(function() {
        $('.%s').clickover({
            html: true,
            title: 'Download information',
            placement: '%s',
            trigger: 'click'
        });
    });""" % (self._opener_class, self.options['doc_position']))))