python类Markup()的实例源码

json.py 文件源码 项目:Texty 作者: sarthfrey 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def tojson_filter(obj, **kwargs):
    return Markup(htmlsafe_dumps(obj, **kwargs))
__init__.py 文件源码 项目:Prism 作者: Stumblinbear 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def do_render(self):
        return jinja2.Markup(prism.handle_render(self.plugin_id, self.render))
helpers.py 文件源码 项目:Prism 作者: Stumblinbear 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def include_static(name):
    """ Load a file from the /static/ directory """
    desired_file = os.path.join(flask_app.static_folder, name)
    with open(desired_file) as f:
        return jinja2.Markup(f.read())
__init__.py 文件源码 项目:Prism 作者: Stumblinbear 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def do_render(self, site_config):
        return jinja2.Markup(prism.handle_render(self.plugin_id, self.render, site_config))
view.py 文件源码 项目:osm-wikidata 作者: EdwardBetts 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def newline_br(eval_ctx, value):
    result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n') \
        for p in _paragraph_re.split(escape(value)))
    if eval_ctx.autoescape:
        result = Markup(result)
    return result
json.py 文件源码 项目:arithmancer 作者: google 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def tojson_filter(obj, **kwargs):
    return Markup(htmlsafe_dumps(obj, **kwargs))
views.py 文件源码 项目:repocribro 作者: MarekSuchanek 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, id, name, priority=100, content='',
                 octicon=None, badge=None):
        self.id = id
        self.name = name
        self.content = jinja2.Markup(content)
        self.priority = priority
        self.octicon = octicon
        self.badge = badge
models.py 文件源码 项目:repocribro 作者: MarekSuchanek 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def gh_user_link(user):
    """Convert user/org to its GitHub URL

    :param repo: User to show its GitHub URL
    :type repo: ``repocribro.models.RepositoryOwner``
    :return: HTML code with hyperlink to GitHub user/org page
    :rtype: ``jinja2.Markup``
    """
    return jinja2.Markup(
        '<a href="https://github.com/{0}" target="_blank">{0}</a>'.format(
            user.login
        )
    )
models.py 文件源码 项目:repocribro 作者: MarekSuchanek 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def gh_repo_link(repo):
    """Convert repo to its GitHub URL

    :param repo: Repository to show its GitHub URL
    :type repo: ``repocribro.models.Repository``
    :return: HTML code with hyperlink to GitHub repo page
    :rtype: ``jinja2.Markup``
    """
    return jinja2.Markup(
        '<a href="https://github.com/{0}" target="_blank">{0}</a>'.format(
            repo.full_name
        )
    )
common.py 文件源码 项目:repocribro 作者: MarekSuchanek 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def email_link(email):
    """Convert email string to HTML link

    :param email: Email address
    :type email: str
    :return: HTML code with hyperlink mailto
    :rtype: ``jinja2.Markup``
    """
    if email is None:
        return ''
    return jinja2.Markup('<a href="mailto:{0}">{0}</a>'.format(email))
test_filters.py 文件源码 项目:repocribro 作者: MarekSuchanek 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_ext_link():
    result = ext_link('https://github.com')
    assert 'https://github.com' in result
    assert 'href="https://github.com"' in result
    assert 'target="_blank"' in result
    assert isinstance(result, jinja2.Markup)
    assert ext_link(None) == ''


# @see http://getbootstrap.com/components/#alerts
test_filters.py 文件源码 项目:repocribro 作者: MarekSuchanek 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def test_gh_user_link():
    user = User(111, 'some', '', '', None, '', '', None, None, None, None)
    result = gh_user_link(user)
    assert user.login in result
    assert 'https://github.com' in result
    assert isinstance(result, jinja2.Markup)
    org = Organization(111, 'some', '', '', None, '', '', None, None)
    result = gh_user_link(org)
    assert org.login in result
    assert 'https://github.com' in result
    assert isinstance(result, jinja2.Markup)
test_filters.py 文件源码 项目:repocribro 作者: MarekSuchanek 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def test_gh_repo_link():
    repo = Repository(777, None, 'some/repo', 'repo', 'C++', '', '',
                      False, None, None, Repository.VISIBILITY_PRIVATE)
    result = gh_repo_link(repo)
    assert repo.full_name in result
    assert 'https://github.com' in result
    assert isinstance(result, jinja2.Markup)
helpers.py 文件源码 项目:pyt 作者: python-security 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def render_markup(text):
    """Renders the given text as markdown

    :param text: The text that should be rendered as markdown
    """
    return Markup(markdown.render(text))
json.py 文件源码 项目:tesismometro 作者: joapaspe 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def tojson_filter(obj, **kwargs):
    return Markup(htmlsafe_dumps(obj, **kwargs))
plugin.py 文件源码 项目:flake8-html 作者: lordmauve 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _format_source(self, source):
        formatter = HtmlFormatter(nowrap=True)
        html = highlight(source, PythonLexer(), formatter)
        return {
            'html_lines': [Markup(l) for l in html.splitlines()],
            'css': formatter.get_style_defs()
        }
json.py 文件源码 项目:RPoint 作者: george17-meet 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def tojson_filter(obj, **kwargs):
    return Markup(htmlsafe_dumps(obj, **kwargs))
json.py 文件源码 项目:isni-reconcile 作者: cmh2166 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def tojson_filter(obj, **kwargs):
    return Markup(htmlsafe_dumps(obj, **kwargs))
__init__.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def include_pagedown(self):
        if request.is_secure:
            protocol = 'https'
        else:
            protocol = 'http'
        return Markup('''
<script type="text/javascript" src="{0}://cdnjs.cloudflare.com/ajax/libs/pagedown/1.0/Markdown.Converter.min.js"></script>
<script type="text/javascript" src="{0}://cdnjs.cloudflare.com/ajax/libs/pagedown/1.0/Markdown.Sanitizer.min.js"></script>
'''.format(protocol))


问题


面经


文章

微信
公众号

扫码关注公众号