本文整理汇总了Python中markdown.md函数的典型用法代码示例。如果您正苦于以下问题:Python md函数的具体用法?Python md怎么用?Python md使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了md函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: markdown
def markdown(s):
s = s or ''
return md(s, [
'markdown.extensions.tables',
'markdown.extensions.fenced_code',
'markdown.extensions.codehilite',
])
示例2: markdown
def markdown(value, autoescape=True):
"""Converts markdown text into html"""
#if autoescape:
# esc = conditional_escape
#else:
# esc = lambda x: x
return mark_safe(md(conditional_escape(value)))
示例3: markdown
def markdown(raw):
html = md(raw, extensions=['gfm'])
if not html.strip():
return html
kill_tags = ['body', 'head', 'style']
cleaner = Cleaner(kill_tags = kill_tags)
html = cleaner.clean_html(html)
return html
示例4: markdown
def markdown(value):
"""
Run text through markdown process
>>> markdown('*test*')
Markup(u'<p><em>test</em></p>')
"""
return Markup(md(value))
示例5: parse_speaker
def parse_speaker(speaker, content):
speaker = speaker.lower().title()
p, created = Post.objects.get_or_create(
thread=t, author=characters[speaker],
content_plain=content)
if created:
p.content_html = sp(md(text=content, extensions=["nl2br"]))
p.creation_date = datetime.datetime.now() # UTC?
p.save()
示例6: markdown
def markdown(value, header_level=1):
html = md(value,
output_format='html5', safe_mode='escape',
extensions=[
TocExtension(baselevel=header_level),
CodeHiliteExtension(),
FencedCodeExtension(),
TableExtension(),
])
return mark_safe(html)
示例7: markdown
def markdown(s, markup_wrap=False):
s = s or ''
s = md(s, [
'markdown.extensions.tables',
'markdown.extensions.fenced_code',
'markdown.extensions.codehilite',
])
if markup_wrap:
s = Markup(s)
return s
示例8: markdown
def markdown(text):
jinja_env = jinja2.Environment()
jinja_env.filters['media_url'] = media_url_func(site)
jinja_env.filters['absolute_url'] = absolute_url_func(site)
jinja_rendered = jinja_env.from_string(text).render()
return md(
jinja_rendered,
tab_length=2,
extensions=['markdown.extensions.fenced_code']
)
示例9: ajax_markdown_preview
def ajax_markdown_preview(request):
d = {}
if request.method == "POST":
raw = request.POST.get('md','')
raw.lstrip()
html = md(raw, extensions=['gfm'])
d['html'] = html
d['code'] = 0
d['msg'] = 'success'
return HttpResponse(json.dumps(d),content_type="application/json")
else:
d['code'] = 1
d['msg'] = 'invalid request method'
return HttpResponse(json.dumps(d),content_type="application/json")
示例10: render_card
def render_card(card):
title = escape(card.title)
image = card.image.url if card.image else None
content = mark_safe(md(conditional_escape(card.content)))
button = card.button
if content:
image_height = 100
else:
image_height = 180
return {'title': title,
'image': image,
'content': content,
'button': button,
'image_height': image_height,}
示例11: mdtext
def mdtext(text):
mdbody = re.sub(
'\\[\\[(.*?)\\]\\]',
lambda match: generate_article_link(match.group(1)),
text
)
mdbody = md(
mdbody,
extensions=[
'markdown.extensions.tables',
'markdown.extensions.footnotes'
],
output_format='html5'
)
return bleach.clean(
mdbody,
tags=ALLOWED_TAGS
)
示例12: sanitise
def sanitise(self, text, markdown = True):
if markdown:
text = md(text)
dom = PyQuery(text)
for a in dom.find('a[href^="javascript:"]'):
a = PyQuery(a)
a.replaceWith(a.text())
for obj in UNCLEAN_TAGS:
dom.find(obj).remove()
for attr in UNCLEAN_ATTRS:
dom.find('[%s]' % attr).removeAttr(attr)
text = dom.outerHtml()
if markdown:
dom = HTML2Text()
text = dom.handle(text)
return text
示例13: api_index
def api_index():
return flask.make_response(md(open('README.md','r').read()))
示例14: markdown
def markdown(s):
return md(s, ['markdown.extensions.tables'])
示例15: markdown
def markdown(post):
page = linkname(post.category.name)
prefix = 'https://s3.amazonaws.com/vineel.me/%s/' % post.id
return Markup(md(post.body, ['awsimage(PREFIX=%s)' % prefix, 'syntax']))