当前位置: 首页>>代码示例>>Python>>正文


Python markdown_deux.markdown函数代码示例

本文整理汇总了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)
开发者ID:jp-mr,项目名称:sfair.org,代码行数:7,代码来源:models.py

示例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 }))
开发者ID:Brachamul,项目名称:elan-democrate,代码行数:9,代码来源:views.py

示例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)
开发者ID:Ambier,项目名称:django-markdown-deux,代码行数:9,代码来源:markdown_deux_tags.py

示例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
开发者ID:MSylvia,项目名称:snipt,代码行数:9,代码来源:models.py

示例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)
开发者ID:JoshAddington,项目名称:hawc,代码行数:9,代码来源:forms.py

示例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)
开发者ID:encolpe,项目名称:apetizer,代码行数:56,代码来源:ui.py

示例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",
        )
开发者ID:thallada,项目名称:personalsite,代码行数:11,代码来源:views.py

示例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
开发者ID:nicksergeant,项目名称:snipt,代码行数:11,代码来源:models.py

示例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
开发者ID:lukexor,项目名称:lukexor_me,代码行数:13,代码来源:models.py

示例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)
开发者ID:Ambier,项目名称:django-markdown-deux,代码行数:18,代码来源:markdown_deux_tags.py

示例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))
开发者ID:xxv,项目名称:asylum-courses,代码行数:5,代码来源:utils.py

示例12: get_markdown

 def get_markdown(self):
     body = self.body
     return mark_safe(markdown(body))
开发者ID:guptachetan1997,项目名称:QnA,代码行数:3,代码来源:models.py

示例13: get_html_description

 def get_html_description(self, obj):
     return markdown_deux.markdown(obj.description)
开发者ID:dburr,项目名称:SchoolIdolAPI,代码行数:2,代码来源:serializers.py

示例14: get_html_message

 def get_html_message(self, obj):
     return markdown_deux.markdown(obj.localized_message_activity)
开发者ID:dburr,项目名称:SchoolIdolAPI,代码行数:2,代码来源:serializers.py

示例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
开发者ID:DemocracyClub,项目名称:Website,代码行数:6,代码来源:views.py


注:本文中的markdown_deux.markdown函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。