• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python markdown_deux.markdown函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中markdown_deux.markdown函数的典型用法代码示例。如果您正苦于以下问题:Python markdown函数的具体用法?Python markdown怎么用?Python markdown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了markdown函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: save

    def save(self, *args, **kwargs):

        if not self.slug:
            self.slug = slugify_uniquely(self.title, Snipt)

        if not self.key:
            self.key = hashlib.md5((self.slug +
                                    str(datetime.datetime.now()) +
                                    str(random.random())).encode('utf-8')).hexdigest()

        if self.lexer == 'markdown':
            self.stylized = markdown(self.code, 'default')

            # Snipt embeds
            for match in re.findall('\[\[(\w{32})\]\]', self.stylized):
                self.stylized = self.stylized.replace('[[' + str(match) + ']]',
                                                      """
                        <script type="text/javascript"
                                   src="https://snipt.net/embed/{}/?snipt">
                           </script>
                       <div id="snipt-embed-{}"></div>""".format(match, match))

            # YouTube embeds
            for match in re.findall('\[\[youtube-(\w{11})\-(\d+)x(\d+)\]\]',
                                    self.stylized):
                self.stylized = self.stylized \
                    .replace('[[youtube-{}-{}x{}]]'.format(
                        str(match[0]),
                        str(match[1]),
                        str(match[2])),
                        """<iframe width="{}" height="{}"
                           src="https://www.youtube.com/embed/{}"
                           frameborder="0" allowfullscreen></iframe>"""
                        .format(match[1], match[2], match[0]))

            # Vimeo embeds
            for match in re.findall('\[\[vimeo-(\d+)\-(\d+)x(\d+)\]\]',
                                    self.stylized):
                self.stylized = self.stylized \
                    .replace('[[vimeo-{}-{}x{}]]'.format(
                        str(match[0]),
                        str(match[1]),
                        str(match[2])),
                        """<iframe src="https://player.vimeo.com/video/{}"
                           width="{}" height="{}" frameborder="0"
                           webkitAllowFullScreen mozallowfullscreen
                           allowFullScreen></iframe>"""
                        .format(match[0], match[1], match[2]))

            # Tweet embeds
            for match in re.findall('\[\[tweet-(\d+)\]\]', self.stylized):
                self.stylized = self.stylized \
                    .replace(
                        '[[tweet-{}]]'.format(str(match)),
                        '<div class="embedded-tweet" data-tweet-id="{}"></div>'
                        .format(str(match)))

            # Parse Snipt usernames
            for match in re.findall('@(\w+) ', self.stylized):

                # Try and get the Snipt user by username.
                user = get_object_or_None(User, username=match)

                if user:
                    url = user.profile.get_user_profile_url()
                    self.stylized = self.stylized \
                        .replace('@{} '.format(str(match)),
                                 '<a href="{}">@{}</a> '.format(url, match))

        else:
            self.stylized = highlight(self.code,
                                      get_lexer_by_name(self.lexer,
                                                        encoding='UTF-8'),
                                      HtmlFormatter(linenos='table',
                                                    anchorlinenos=True,
                                                    lineanchors='L',
                                                    linespans='L',
                                                    ))
        self.line_count = len(self.code.split('\n'))

        if self.lexer == 'markdown':
            lexer_for_embedded = 'text'
        else:
            lexer_for_embedded = self.lexer

        embedded = highlight(self.code,
                             get_lexer_by_name(lexer_for_embedded,
                                               encoding='UTF-8'),
                             HtmlFormatter(
                                 style='native',
                                 noclasses=True,
                                 prestyles="""
                                     background-color: #1C1C1C;
                                     border-radius: 5px;
                                     color: #D0D0D0;
                                     display: block;
                                     font: 11px Monaco, monospace;
                                     margin: 0;
                                     overflow: auto;
                                     padding: 15px;
#.........这里部分代码省略.........
开发者ID:ScriptSB,项目名称:snipt,代码行数:101,代码来源:models.py


示例17: save

    def save(self, *args, **kwargs):

        if not self.slug:
            self.slug = slugify_uniquely(self.title, Snipt)

        if not self.key:
            self.key = md5.new(self.slug + str(datetime.datetime.now()) + str(random.random())).hexdigest()

        if self.lexer == 'markdown':
            self.stylized = markdown(self.code, 'default')

            # Snipt embeds
            for match in re.findall('\[\[(\w{32})\]\]', self.stylized):
                self.stylized = self.stylized.replace('[[' + str(match) + ']]',
                    '<script type="text/javascript" src="https://snipt.net/embed/{}/?snipt"></script><div id="snipt-embed-{}"></div>'.format(match, match))

            # YouTube embeds
            for match in re.findall('\[\[youtube-(\w{11})\-(\d+)x(\d+)\]\]', self.stylized):
                self.stylized = self.stylized.replace('[[youtube-{}-{}x{}]]'.format(str(match[0]), str(match[1]), str(match[2])),
                    '<iframe width="{}" height="{}" src="https://www.youtube.com/embed/{}" frameborder="0" allowfullscreen></iframe>'.format(match[1], match[2], match[0]))

            # Vimeo embeds
            for match in re.findall('\[\[vimeo-(\d+)\-(\d+)x(\d+)\]\]', self.stylized):
                self.stylized = self.stylized.replace('[[vimeo-{}-{}x{}]]'.format(str(match[0]), str(match[1]), str(match[2])),
                    '<iframe src="https://player.vimeo.com/video/{}" width="{}" height="{}" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'.format(match[0], match[1], match[2]))

        else:
            self.stylized = highlight(self.code,
                                      get_lexer_by_name(self.lexer, encoding='UTF-8'),
                                      HtmlFormatter(linenos='table', linenospecial=1, lineanchors='line'))
        self.line_count = len(self.code.split('\n'))

        if self.lexer == 'markdown':
            lexer_for_embedded = 'text'
        else:
            lexer_for_embedded = self.lexer

        embedded = highlight(self.code,
                             get_lexer_by_name(lexer_for_embedded, encoding='UTF-8'),
                             HtmlFormatter(
                                 style='native',
                                 noclasses=True,
                                 prestyles="""
                                     background-color: #1C1C1C;
                                     border-radius: 5px;
                                     color: #D0D0D0;
                                     display: block;
                                     font: 11px Monaco, monospace;
                                     margin: 0;
                                     overflow: auto;
                                     padding: 15px;
                                     -webkit-border-radius: 5px;
                                     -moz-border-radius: 5px;
                                     """))
        embedded = (embedded.replace("\\\"","\\\\\"")
                            .replace('\'','\\\'')
                            .replace("\\", "\\\\")
                            .replace('background: #202020', ''))
        self.embedded = embedded

        return super(Snipt, self).save(*args, **kwargs)
开发者ID:MSylvia,项目名称:snipt,代码行数:61,代码来源:models.py


示例18: item_description

 def item_description(self, item):
     return markdown_deux.markdown(item.text, style='post_style')
开发者ID:thallada,项目名称:personalsite,代码行数:2,代码来源:models.py


示例19: get_markdown

 def get_markdown(self):
     experience_required = self.experience_required
     markdown_text = markdown(experience_required)
     return mark_safe(markdown_text)
开发者ID:afaizan,项目名称:SNTwebapp,代码行数:4,代码来源:models.py


示例20: get_markdown

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python market.Market类代码示例发布时间:2022-05-27
下一篇:
Python markdown_adapter.run_markdown函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap