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

Python mistune.markdown函数代码示例

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

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



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

示例1: create_issue

    def create_issue(self, data, **kwargs):
        """
        Creates the issue on the remote service and returns an issue ID.
        """
        project_id = data.get('project')
        if project_id is None:
            raise ValueError('Azure DevOps expects project')

        client = self.get_client()

        title = data['title']
        description = data['description']

        try:
            created_item = client.create_work_item(
                instance=self.instance,
                project=project_id,
                title=title,
                # Decriptions cannot easily be seen. So, a comment will be added as well.
                description=markdown(description),
                comment=markdown(description)
            )
        except Exception as e:
            self.raise_error(e)

        project_name = created_item['fields']['System.AreaPath']
        return {
            'key': six.text_type(created_item['id']),
            'title': title,
            'description': description,
            'metadata': {
                'display_name': '%s#%s' % (project_name, created_item['id']),
            }
        }
开发者ID:getsentry,项目名称:sentry,代码行数:34,代码来源:issues.py


示例2: import_file

    def import_file(cls,path=None):
        '''
        导入博客文件,自动跳过已导入的文件。
        '''
        path=abspath(path or '~/OneDrive/notes')
        note_files=[]
        for root,paths,files in os.walk(path):
            note_files.extend([join(root,fi) for fi in files
                               if fi.endswith('.md')])

        for fl in cls.find({'filename':{"$in":note_files}},
                                 {'mtime':1,'filename':1}):
            if fl['mtime']>=dt_tz(os.path.getmtime(fl['filename'])):
                print('文件:%s 已导入,跳过'%(fl['filename']))
                note_files.remove(fl['filename'])
        renderer=ConvertRenderer()
        for filename in note_files:
            body='\n'.join(read_file(filename))
            renderer.clear()
            mistune.markdown(body,renderer=renderer)
            cls.update_one({'filename':filename},
                       {'$set':
                        {'title':renderer.title,
                         'abbr':renderer.abbr,
                         'meta':renderer.meta,
                         'mtime':dt_tz(os.path.getmtime(filename)),
                         'ctime':dt_tz(os.path.getctime(filename)),
                        'body':body}},
                         True)
开发者ID:huangtao-sh,项目名称:mongo,代码行数:29,代码来源:blog.py


示例3: _pre_put_hook

    def _pre_put_hook(self):
        if not self.original_name:
            self.original_name = self.name
        self.name = clean_name(self.name)
        self.category = strip_string(self.category)
        self.badge = strip_string(self.badge)
        self.barcode = strip_string(self.barcode)
        self.brand = strip_string(self.brand)
        self.country = strip_string(self.country)
        self.material = strip_string(self.material)

        self.description_md = self.description_md.strip()
        if self.description_md:
          self.description_html = mistune.markdown(self.description_md)
          self.description = re.sub(
              r'(<!--.*?-->|<[^>]*>)', '', self.description_html)
        else:
          self.description = self.description.strip()
          self.description_md = self.description
          self.description_html = mistune.markdown(self.description)
        if self.description:
            self.short_description = u' '.join(self.description.split()[:5])
        else:
            self.short_description = ''
        self.meta_keywords = self.clear_name.replace(' ', ', ')
开发者ID:gmist,项目名称:3dhero.ru,代码行数:25,代码来源:models.py


示例4: test_parse_block_html

def test_parse_block_html():
    ret = mistune.markdown(
        '<div>**foo**</div>', parse_block_html=True, escape=False
    )
    assert '<div><strong>' in ret
    ret = mistune.markdown(
        '<span>**foo**</span>', parse_block_html=True, escape=False
    )
    assert '<strong>' not in ret
开发者ID:jonathan-s,项目名称:mistune,代码行数:9,代码来源:test_extra.py


示例5: add_post_post

def add_post_post():
    post = Word(
      title = request.form["title"],
      content = mistune.markdown(request.form["content"]),
      category = mistune.markdown(request.form["category"]),
      level = mistune.markdown(request.form["level"]),
      author = current_user
    )
    session.add(post)
    session.commit()
    return redirect(url_for("words"))
开发者ID:feeneyp,项目名称:synonyms,代码行数:11,代码来源:views.py


示例6: test_use_xhtml

def test_use_xhtml():
    ret = mistune.markdown('foo\n\n----\n\nbar')
    assert '<hr>' in ret
    ret = mistune.markdown('foo\n\n----\n\nbar', use_xhtml=True)
    assert '<hr />' in ret

    ret = mistune.markdown('foo  \nbar', use_xhtml=True)
    assert '<br />' in ret

    ret = mistune.markdown('![foo](bar "title")', use_xhtml=True)
    assert '<img src="bar" alt="foo" title="title" />' in ret
开发者ID:despiegk,项目名称:mistune,代码行数:11,代码来源:test_extra.py


示例7: __init__

 def __init__(self, proto):
   self.__proto = proto
   self.name = proto.name
   self.documentation = mistune.markdown(proto.documentation)
   self.example_documentation = mistune.markdown(proto.example_documentation)
   self.signature = self._get_signature(proto)
   self.attributes = []
   for attribute in proto.attribute:
     self.attributes.append(Attribute(attribute))
   self.outputs = []
   for output in proto.output:
     self.outputs.append(Output(output))
开发者ID:guymers,项目名称:skydoc,代码行数:12,代码来源:rule.py


示例8: _grab_blocks

 def _grab_blocks(self):
     """
     Parse `self.source` and return a dict mapping block names to their
     raw content.
     """
     r = BlockRecordRenderer()
     mistune.markdown(self.source, renderer=r)
 
     blocks = {}
     for block in r.blocks:
         name, content = self._parse_raw_block(block)
         blocks[name] = content        
     self.blocks = blocks
开发者ID:ianpreston,项目名称:album,代码行数:13,代码来源:compiler.py


示例9: test_parse_nested_html

def test_parse_nested_html():
    ret = mistune.markdown(
        '<div><a href="http://example.org">**foo**</a></div>',
        parse_block_html=True, escape=False
    )
    assert '<div><a href="http://example.org">' in ret
    assert '<strong>' not in ret

    ret = mistune.markdown(
        '<div><a href="http://example.org">**foo**</a></div>',
        parse_block_html=True, parse_inline_html=True, escape=False
    )
    assert '<div><a href="http://example.org"><strong>' in ret
开发者ID:despiegk,项目名称:mistune,代码行数:13,代码来源:test_extra.py


示例10: test_parse_inline_html

def test_parse_inline_html():
    ret = mistune.markdown(
        '<div>**foo**</div>', parse_inline_html=True, escape=False
    )
    assert '<strong>' not in ret
    ret = mistune.markdown(
        '<span>**foo**</span>', parse_inline_html=True, escape=False
    )
    assert '<span><strong>' in ret

    ret = mistune.markdown(
        '<a>http://lepture.com</a>', parse_inline_html=True, escape=False
    )
    assert 'href' not in ret
开发者ID:jonathan-s,项目名称:mistune,代码行数:14,代码来源:test_extra.py


示例11: index

def index():
	
	
	dirs = _get_dirs()
	
	main_index = dict(standard="1377", issue="1990", org="BS", title="BS1377:1990", parts=[])
	
	
	print dirs
	for d in dirs:
		files = _get_md_files(d)
		print "d=", d
		#print "==========", ROOT_PATH + d + "/README.md"
		txt =  _read_file(ROOT_PATH + d + "/README.md")
		html = mistune.markdown(txt)
		soup = BeautifulSoup(html)
		
		dic = {}
		dic['title'] = str(soup.find("h1").text).strip()
		dic['part'] = dic['title'][4:].strip().split(" ")[0].strip()
		#dic['sections'] = []

		
		idx = []
		for f in files:
			#print f
			txt =  _read_file(ROOT_PATH + f)
			html = mistune.markdown(txt)
			#print html
			soup = BeautifulSoup(html)
			print "------------------------------"
			title =  str(soup.find("h1").text).strip()
			toc = []
			for h2 in soup.findAll("h2"):
				toc.append( dict(title=str(h2.text).strip()) ) 
			#print title, toc
			#'toc.append( dict(file=f, title=title, toc=toc) )
			#fff =  f
			#print f, fff
			num = f.split("/")[-1][:-3]
			print "NO = ", num, type(num)
			data = dict(title=title, clauses=toc, file=f, part= str(d)[1:], org="BS", section=num)
			idx.append( data )
		dic['sections'] = idx
		_write_yaml("%s/%s/index.yaml" % (ROOT_PATH, d), dic )
		main_index['parts'].append(dic)
		#print idx
		#break
	
	_write_yaml("%s/index.yaml" % (ROOT_PATH), main_index )	
开发者ID:pedromorgan,项目名称:1377,代码行数:50,代码来源:fabfile.py


示例12: generate_post

    def generate_post(self, text, out_file_name):
        html = mistune.markdown(text, escape=False)
        result = self.blog_template.format(
            content=html, blog_name=self.blog_name)

        with open(out_file_name, "w+") as f:
            f.write(result)
开发者ID:skyline75489,项目名称:Genie,代码行数:7,代码来源:genie.py


示例13: get_html

 def get_html(self):
     if self.text_type == 'rst':
         from docutils.core import publish_parts
         return publish_parts(self.text, writer_name='html')['html_body']
     else:
         import mistune
         return mistune.markdown(self.text)
开发者ID:ashumeow,项目名称:petroglyph,代码行数:7,代码来源:post.py


示例14: markdownDeck

def markdownDeck(deck):
    fl = open("decords/{}".format(deck), "r")
    xml = mistune.markdown(fl.read())
    fl.close()
    del (fl)
    xml = etree.fromstring(xml)
    pass
开发者ID:TristanTrim,项目名称:urcards,代码行数:7,代码来源:urcards.py


示例15: markdownify

def markdownify():
    md = request.form.get("markdown")
    if md:
        html = mistune.markdown(md)
        return html
    else:
        return "no markdown supplied"
开发者ID:ahmadfaizalbh,项目名称:rodeo,代码行数:7,代码来源:rodeo.py


示例16: render

def render(file):
    """Render HTML from Markdown file content."""
    fp = file.open()
    content = fp.read()
    result = mistune.markdown(content.decode('utf-8'))
    fp.close()
    return result
开发者ID:slint,项目名称:invenio-previewer,代码行数:7,代码来源:mistune.py


示例17: render

 def render(self, context):
     value = self.nodelist.render(context)
     try:
         return mark_safe(mistune.markdown(value))
     except ImportError:
         raise template.TemplateSyntaxError("Error in `markdown` tag: "
                 "The mistune library isn't installed.")
开发者ID:chop-dbhi,项目名称:mybic,代码行数:7,代码来源:markdown_tags.py


示例18: edit_post_post

def edit_post_post(id):
    post = session.query(Post).get(id)
    post.title=request.form["title"]
    post.content=mistune.markdown(request.form["content"])
    session.add(post)
    session.commit()
    return redirect(url_for("view_post", id=post.id))
开发者ID:BostonREB,项目名称:blog,代码行数:7,代码来源:views.py


示例19: job

def job(job_id):
    '''
    View a single job (any status) with AJAX callback to update elements, e.g.
        - STDOUT/STDERR
        - File outputs (figures, etc.), intelligent render handling
        - Download link for all files


    :param job_id:
    :return:
    '''

    # Get the job object from the database
    job = Job.query.get(job_id)
    script = job.script
    display = {}

    cwd = os.path.join(job.path, 'output')  # Excution path of the job
    if os.path.isdir(cwd):  # Execution has begun/finished

        files = job.get_output_files()
        display = build_display_objects(files)

    documentation = script.load_docs()
    if documentation:
        documentation = mistune.markdown(documentation)

    return render_template("public/job.html", script=script, job=job, metadata=script.load_config(), display=display,
                           documentation=documentation)
开发者ID:LukeLevesque,项目名称:Wooey,代码行数:29,代码来源:views.py


示例20: edit_post_post

def edit_post_post(post_id):
    post=session.query(Post).get(post_id)
    post.title = request.form["title"]
    post.content = mistune.markdown(request.form["content"])
    
    session.commit()
    return redirect(url_for("posts"))
开发者ID:jon-xavier,项目名称:blogful,代码行数:7,代码来源:views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python logger.get_module_logging函数代码示例发布时间:2022-05-27
下一篇:
Python mistune.escape函数代码示例发布时间: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