How to use the genshi.core.Markup function in Genshi

To help you get started, we’ve selected a few Genshi 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 timonwong / OmniMarkupPreviewer / OmniMarkupLib / Renderers / libs / python2 / genshi / output.py View on Github external
for attr, value in attrib:
                    if attr in boolean_attrs:
                        value = attr
                    elif attr == 'xml:lang' and 'lang' not in attrib:
                        buf += [' lang="', escape(value), '"']
                    elif attr == 'xml:space':
                        continue
                    buf += [' ', attr, '="', escape(value), '"']
                if kind is EMPTY:
                    if tag in empty_elems:
                        buf.append(' />')
                    else:
                        buf.append('>' % tag)
                else:
                    buf.append('>')
                yield _emit(kind, data, Markup(''.join(buf)))

            elif kind is END:
                yield _emit(kind, data, Markup('' % data))

            elif kind is TEXT:
                if in_cdata:
                    yield _emit(kind, data, data)
                else:
                    yield _emit(kind, data, escape(data, quotes=False))

            elif kind is COMMENT:
                yield _emit(kind, data, Markup('' % data))

            elif kind is DOCTYPE and not have_doctype:
                name, pubid, sysid = data
                buf = ['
github pinax / pinax / libs / external_libs / Genshi-0.5.1 / genshi / output.py View on Github external
tag, attrib = data
                buf = ['<', tag]
                for attr, value in attrib:
                    if attr in boolean_attrs:
                        if value:
                            buf += [' ', attr]
                    elif ':' in attr:
                        if attr == 'xml:lang' and u'lang' not in attrib:
                            buf += [' lang="', escape(value), '"']
                    elif attr != 'xmlns':
                        buf += [' ', attr, '="', escape(value), '"']
                buf.append('>')
                if kind is EMPTY:
                    if tag not in empty_elems:
                        buf.append('' % tag)
                yield Markup(u''.join(buf))
                if tag in noescape_elems:
                    noescape = True

            elif kind is END:
                yield Markup('' % data)
                noescape = False

            elif kind is TEXT:
                if noescape:
                    yield data
                else:
                    yield escape(data, quotes=False)

            elif kind is COMMENT:
                yield Markup('' % data)
github edgewall / trac / tracopt / mimeview / enscript.py View on Github external
if np.errorlevel or np.err:
            self.env.disable_component(self)
            err = "Running enscript failed with (%s, %s), disabling " \
                  "EnscriptRenderer (command: '%s')" \
                  % (np.errorlevel, np.err.strip(), cmdline)
            raise Exception(err)
        odata = np.out

        # Strip header and footer
        i = odata.find('<pre>')
        beg = i &gt; 0 and i + 6
        i = odata.rfind('</pre>')
        end = i if i &gt; 0 else len(odata)

        odata = EnscriptDeuglifier().format(odata[beg:end].decode('utf-8'))
        return [Markup(line) for line in odata.splitlines()]
github tmshlvck / ulg / ulgmodel.py View on Github external
def preprocessTableCell(td):
            if(isinstance(td,(list,tuple))):
                if(len(td) >= 2):
                    return (Markup(str(td[0])),Markup(str(td[1])))
                elif(len(td) == 1):
                    return (Markup(str(td[0])),Markup(TableDecorator.WHITE))
                else:
                    return ('',Markup(TableDecorator.WHITE))
            else:
                return (Markup(str(td)),Markup(TableDecorator.WHITE))
github pinax / pinax / libs / external_libs / Genshi-0.5.1 / genshi / output.py View on Github external
yield escape(data, quotes=False)

            elif kind is COMMENT:
                yield Markup('' % data)

            elif kind is DOCTYPE and not have_doctype:
                name, pubid, sysid = data
                buf = ['\n')
                yield Markup(u''.join(buf)) % filter(None, data)
                have_doctype = True

            elif kind is PI:
                yield Markup('' % data)
github apache / bloodhound / trac / trac / util / presentation.py View on Github external
def istext(text):
    """`True` for text (`unicode` and `str`), but `False` for `Markup`."""
    from genshi.core import Markup
    return isinstance(text, basestring) and not isinstance(text, Markup)
github edgewall / genshi / genshi / core.py View on Github external
def striptags(self):
        """Return a copy of the text with all XML/HTML tags removed.
        
        :return: a `Markup` instance with all tags removed
        :rtype: `Markup`
        :see: `genshi.util.striptags`
        """
        return Markup(striptags(self))
github apache / bloodhound / bloodhound_multiproduct / multiproduct / api.py View on Github external
def _make_sublink(self, env, sublink, formatter, ns, target, label,
                      fullmatch, extra=''):
        parent_match = {'ns' : ns,
                        'target' : target,
                        'label': Markup(escape(unescape(label)
                                               if isinstance(label, Markup)
                                               else label)),
                        'fullmatch' : fullmatch,
                        }

        # Tweak nested context to work in target product/global scope
        subctx = formatter.context.child()
        subctx.href = resolve_product_href(to_env=env, at_env=self.env)
        try:
            req = formatter.context.req
        except AttributeError:
            pass
        else:
            # Authenticate in local context but use foreign permissions
            subctx.perm = self.FakePermClass() \
                            if isinstance(req.session, FakeSession) \
github mediadrop / mediadrop / mediadrop / lib / players.py View on Github external
def render_js_player(self):
        return Markup("new mcore.Html5Player()")
github tmshlvck / ulg / ulg.py View on Github external
def renderULGError(self,sessionid=None,**params):
        template = self.loader.load(defaults.index_template_file)

        result_text = defaults.STRING_ARBITRARY_ERROR

        session = loadSession(sessionid)
        if(session!=None):
            result_text=self.decorator_helper.pre(self.sessions[sessionid].getError())

        return template.generate(defaults=defaults,
                                 routers=config.routers,
                                 commonparams=self.getCommonParams(),
                                 default_routerid=0,
                                 default_commandid=0,
                                 default_sessionid=None,
                                 result=Markup(result_text) if(result_text) else None,
                                 refresh=0,
                                 getFormURL=self.decorator_helper.getRuncommandURL,
                                 user=self.user
                                 ).render('html', doctype='html', encoding='utf-8')