本文整理汇总了Python中markdown_deux.markdown函数的典型用法代码示例。如果您正苦于以下问题:Python markdown函数的具体用法?Python markdown怎么用?Python markdown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了markdown函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_markdown
def get_markdown(self):
description = self.description
# TODO: escapar os caracteres especiais dentro das tags do TeX
# tex_parser = re.compile(r'\$(.*?)\$')
# description = tex_parser.finditer(description)
markdown_text = markdown(description)
return mark_safe(markdown_text)
示例2: NewMessage
def NewMessage(request, channel_slug):
channel = get_object_or_404(Channel, slug=channel_slug)
if request.method == "POST" :
if channel.is_default or request.user in channel.subscribers.all() :
content = markdown(request.POST.get('message'))
new_message = Message(author=request.user, channel=channel, content=content)
new_message.save()
else : messages.error(request, "Une erreur s'est produite. Vous n'avez peut-être pas les droits pour envoyer ce message.")
return HttpResponseRedirect(reverse('chatroom', kwargs={ 'channel_slug': channel_slug }))
示例3: render
def render(self, context):
value = self.nodelist.render(context)
try:
return mark_safe(markdown_deux.markdown(value, self.style))
except ImportError:
if settings.DEBUG:
raise template.TemplateSyntaxError("Error in `markdown` tag: "
"The python-markdown2 library isn't installed.")
return force_text(value)
示例4: get_stylized_min
def get_stylized_min(self):
if self.stylized_min is None:
if self.lexer == 'markdown':
self.stylized_min = markdown(self.code[:1000], 'default')
else:
self.stylized_min = highlight(self.code[:1000],
get_lexer_by_name(self.lexer, encoding='UTF-8'),
HtmlFormatter(linenos='table', linenospecial=1, lineanchors='line'))
return self.stylized_min
示例5: send_email
def send_email(self):
from_email = settings.DEFAULT_FROM_EMAIL
subject = "[HAWC] {0}" .format(self.cleaned_data['subject'])
message = ""
recipient_list = self.assessment.get_project_manager_emails()
html_message = markdown(self.cleaned_data['message'])
send_mail(subject, message, from_email, recipient_list,
html_message=html_message,
fail_silently=False)
示例6: process_related
def process_related(self, request, user_profile, input_data, template_args, **kwargs):
"""
Displays and manages the item related_url behavior
Her is the switch for external services integration
"""
# check if related-url is set
# and switch depending on the service it represents
# it's much more like an embed
#
# check for url
node = kwargs['node']
if node.related_url:
if node.related_url.startswith('https://twitter.com') and input_data.get('keyword'):
wk = TwitterWorker(user_profile, kwargs['node'], input_data, kwargs)
items = wk.prepare()
template_args['nodes'] = items
#return self.render(request, template_args, **kwargs)
elif node.related_url.startswith('http://www.meetup.com'):
# and
#input_data.get('keyword'):
wk = MeetupWorker(user_profile, kwargs['node'], input_data, kwargs)
items = wk.prepare()
template_args['nodes'] = items
#return self.render(request, template_args, **kwargs)
elif node.related_url.startswith('https://googlecalendar.com'):
pass
elif node.related_url.startswith('https://hackpad.com/'):
hackpad_id = node.related_url.split('-')[-1]
print 'importing hackpad'
# import hackpad content
HACKPAD_CLIENT_ID = 'vTuK1ArKv5m'
HACKPAD_CLIENT_SECRET = '5FuDkwdgc8Mo0y2OuhMijuzFfQy3ni5T'
hackpad = Hackpad(consumer_key=HACKPAD_CLIENT_ID, consumer_secret=HACKPAD_CLIENT_SECRET)
#node.description = ''
#node.description = hackpad.get_pad_content(hackpad_id, asUser='', response_format='md')
hackpad_content = hackpad.get_pad_content(hackpad_id, asUser='', response_format='md')
#node.description = unicode(decode(hackpad_content, 'latin1'))
try:
node.get_translation().content = markdown_deux.markdown( unicode(decode(hackpad_content, 'latin1')) )
node.save()
except:
pass
#print node.content
return self.manage_item_pipe(request, user_profile, input_data, template_args, **kwargs)
示例7: markdown_comment
def markdown_comment(request):
# Exclusively for ajax posts. Return a user's comment in markdown converted
# to safe html for posting.
if request.is_ajax():
return HttpResponse(
json.dumps(
{"comment": markdown_deux.markdown(request.POST.get("comment", ""), style="comment_style")},
ensure_ascii=False,
),
mimetype="application/javascript",
)
示例8: get_stylized_min
def get_stylized_min(self):
if self.stylized_min is None:
if self.lexer == "markdown":
self.stylized_min = markdown(self.code[:1000], "default")
else:
self.stylized_min = highlight(
self.code[:1000],
get_lexer_by_name(self.lexer, encoding="UTF-8"),
HtmlFormatter(linenos="table", linenospecial=1, lineanchors="line"),
)
return self.stylized_min
示例9: summary_text
def summary_text(text, length=40):
html_text = markdown_deux.markdown(text, "trusted")
stripped_text = strip_tags(html_text).strip()
word_separator = re.compile('[ ]')
words = word_separator.split(stripped_text)
if len(words) > length:
shortened_text = "%s ..." % (' '.join(words[0:length]))
else:
shortened_text = ' '.join(words)
return shortened_text
示例10: markdown_filter
def markdown_filter(value, style="default"):
"""Processes the given value as Markdown, optionally using a particular
Markdown style/config
Syntax::
{{ value|markdown }} {# uses the "default" style #}
{{ value|markdown:"mystyle" }}
Markdown "styles" are defined by the `MARKDOWN_DEUX_STYLES` setting.
"""
try:
return mark_safe(markdown_deux.markdown(value, style))
except ImportError:
if settings.DEBUG:
raise template.TemplateSyntaxError("Error in `markdown` filter: "
"The python-markdown2 library isn't installed.")
return force_text(value)
示例11: multipart_markdown
def multipart_markdown(md_text, template_text=True):
if template_text:
md_text = Template(md_text).render(TemplateTextContext())
return to_multipart(md_text, markdown(md_text))
示例12: get_markdown
def get_markdown(self):
body = self.body
return mark_safe(markdown(body))
示例13: get_html_description
def get_html_description(self, obj):
return markdown_deux.markdown(obj.description)
示例14: get_html_message
def get_html_message(self, obj):
return markdown_deux.markdown(obj.localized_message_activity)
示例15: get_context_data
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
md = get_template(self.template_name).template.source
md_with_toc = markdown_deux.markdown(md, "default")
context["toc"] = md_with_toc.toc_html
return context