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

Python markdown.markdownFromFile函数代码示例

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

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



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

示例1: gendoc

def gendoc(fpath, md_extensions = []):
    """generate html doc as string from source markdown file"""

    if not path.isfile (fpath):
        """check path is a file"""
        bottle.abort(400, 'invalid file: %s' % fpath)

    @bottle.view('htdoc_head')
    @tpl_data(fpath)
    @tpl_utils
    def htdoc_head():
        """render htdoc head template"""
        return dict()

    @bottle.view('htdoc_tail')
    @tpl_data(fpath)
    @tpl_utils
    def htdoc_tail():
        """render htdoc tail template"""
        return dict()

    # parse markdown file
    buf = io.BytesIO()
    try:
        markdownFromFile(input = fpath, extensions = md_extensions,
                output = buf, output_format = 'html5')
    except FileNotFoundError as err:
        bottle.abort(404, str(err))
    else:
        buf.seek(0, 0)

    # generate response
    return htdoc_head() + buf.read().decode() + htdoc_tail()
开发者ID:jrmsdev,项目名称:bottled-md,代码行数:33,代码来源:bmd.py


示例2: read_page

def read_page(filename):
    page = dict()
    page['id'] = os.path.splitext(os.path.basename(filename))[0]
    string_file = StringIO.StringIO()
    markdown.markdownFromFile(input=filename, output=string_file)
    page['content'] =  string_file.getvalue()
    return page
开发者ID:paxanima,项目名称:beers,代码行数:7,代码来源:beers.py


示例3: get

    def get(self, request, *args, **kwargs):
        contest_slug = kwargs['contest']
        problem_letter = kwargs['problem']
        problem_text = ''
        contest = get_object_or_404(Contest, active=True, start__lte=now(), slug=contest_slug)
        user = request.user.member 
        first_name = request.user.first_name
        if not entry_exists(user, contest):
            HttpRedirect('/contest-gateway')
        
        problem = get_object_or_404(Problem, letter=problem_letter)

        if problem not in contest.problems.all():
            raise Http404

        
        try:
            buff = StringIO()
            index_file = 'grader/contests/' + contest_slug + '/' + problem_letter + '.md'
            markdownFromFile(input=index_file, output=buff)
            problem_text = buff.getvalue()
        except IOError:
            raise Http404

        return render(request, self.template, {'problem':problem,
                                               'problem_text':problem_text,
                                               'first_name':first_name,})
开发者ID:abigopal,项目名称:sct-grader,代码行数:27,代码来源:contest.py


示例4: run

def run():
    options, logging_level = parse_options()
    if not options:
        sys.exit(2)
    logger.setLevel(logging_level)
    logger.addHandler(logging.StreamHandler())
    markdown.markdownFromFile(**options)
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:7,代码来源:__main__.py


示例5: plugin_markdown

def plugin_markdown(parameters=[]):
    result = []
    for parameter in parameters:
        filename = parameter + '.html'
        markdown.markdownFromFile(parameter, filename)
        result.append(filename)
    return result
开发者ID:turicas,项目名称:old-pypelinin-text,代码行数:7,代码来源:plugins.py


示例6: MakeSourceDist

def MakeSourceDist( ):
	distDir = "imfit-%s/" % VERSION_STRING
	final_file_list = example_file_list + misc_required_files_list + documentation_file_list
	final_file_list += extras_file_list
	final_file_list += funcobj_file_list
	final_file_list += solvers_file_list
	final_file_list += mcmc_file_list
	final_file_list += core_file_list
	final_file_list += python_file_list
	final_file_list += testing_scripts_list
	final_file_list += test_file_imfit_list
	final_file_list += test_file_mcmc_list
	final_file_list += test_file_makeimage_list
	final_file_list += test_file_list
	final_file_list.append("SConstruct")
	
	tar = tarfile.open(SOURCE_TARFILE, 'w|gz') 
	for fname in final_file_list:
		tar.add(distDir + fname)
	tar.close()
	
	print("Copying gzipped tar file %s to %s..." % (SOURCE_TARFILE, SOURCE_COPY_DEST_DIR))
	shutil.copy(SOURCE_TARFILE, SOURCE_COPY_DEST_DIR)
	print("Generating HTML version of CHANGELOG.md and copying to %s..." % (MAC_CHANGELOG_DEST))
	markdown.markdownFromFile(input=MAC_CHANGELOG_MD, output=MAC_CHANGELOG_DEST)
开发者ID:perwin,项目名称:imfit,代码行数:25,代码来源:make_distributions.py


示例7: render_markdown_from_file

def render_markdown_from_file(f, **markdown_kwargs):
    """Render Markdown text from a file stream to HTML."""
    s = StringIO()
    markdownFromFile(input=f, output=s, **markdown_kwargs)
    html = s.getvalue()
    s.close()

    return html
开发者ID:chipx86,项目名称:djblets,代码行数:8,代码来源:__init__.py


示例8: section_to_html

def section_to_html(section):
    """
    Convert a markdown file in the markdown folder and convert it
    into a template snippet in the templates folder
    """
    md_fil_name = 'markdown/{}.md'.format(section)
    html_fil_name = 'templates/{}.html'.format(section)
    markdown.markdownFromFile(input=md_fil_name, output=html_fil_name)
开发者ID:swizzard,项目名称:swizzarddotpizza,代码行数:8,代码来源:md_to_html.py


示例9: process_md

def process_md(md, h_str, f_str, indir, outdir):
    outfilename = os.path.join(outdir, md[0:-3] + ".html")
    infilename = os.path.join(indir, md)

    with open(outfilename, "w") as f:
        f.write(h_str)
        markdownFromFile(output_format="xhtml1",input=infilename, output=f)
        f.write(f_str)
开发者ID:juanfra684,项目名称:vwww,代码行数:8,代码来源:vwww.py


示例10: _render

    def _render(self):
        buffer = StringIO()
        self.obj.file.open()
        markdown.markdownFromFile(input=self.obj.file, output=buffer, output_format="xhtml1", safe_mode="escape")
        rendered = buffer.getvalue()
        buffer.close()

        return rendered
开发者ID:reedloden,项目名称:reviewboard,代码行数:8,代码来源:markdownui.py


示例11: get_post_content

def get_post_content(dir, post_time, post_name):
    file_name = os.path.join(dir, post_time + '-' + post_name + '.md')
    if not os.path.exists(file_name):
        return None
    output = StringIO.StringIO()
    markdown.markdownFromFile(input = file_name, output = output, extensions = ['markdown.extensions.tables'])
    content = output.getvalue()
    output.close()
    return content
开发者ID:airtrack,项目名称:blog,代码行数:9,代码来源:post.py


示例12: main

def main():
    # Available output formats are:
    # - "xhtml1": Outputs XHTML 1.x. Default.
    # - "xhtml5": Outputs XHTML style tags of HTML 5
    # - "xhtml": Outputs latest supported version of XHTML (currently XHTML 1.1).
    # - "html4": Outputs HTML 4
    # - "html5": Outputs HTML style tags of HTML 5
    # - "html": Outputs latest supported version of HTML (currently HTML 4).
    markdown.markdownFromFile(input="test.md", output="test.html", output_format="html5")
开发者ID:jeremiedecock,项目名称:snippets,代码行数:9,代码来源:markdown_to_html_file_from_md_file.py


示例13: run

def run():
    """Run Markdown from the command line."""

    # Parse options and adjust logging level if necessary
    options, logging_level = parse_options()
    if not options: sys.exit(0)
    if logging_level: logging.getLogger('MARKDOWN').setLevel(logging_level)

    # Run
    markdown.markdownFromFile(**options)
开发者ID:20after4,项目名称:Yaki,代码行数:10,代码来源:commandline.py


示例14: load_legal_doc

def load_legal_doc(request, doc_name):
    """
    Load a static Markdown file and return the document as a BeautifulSoup
    object for easier manipulation.
    """
    locale = l10n_utils.get_locale(request)
    source = path.join(LEGAL_DOCS_PATH, doc_name, locale + '.md')
    output = StringIO.StringIO()

    if not path.exists(source):
        source = path.join(LEGAL_DOCS_PATH, doc_name, 'en-US.md')

    # Parse the Markdown file
    md.markdownFromFile(input=source, output=output,
                        extensions=['attr_list', 'outline(wrapper_cls=)'])
    content = output.getvalue().decode('utf8')
    output.close()

    soup = BeautifulSoup(content)
    hn_pattern = re.compile(r'^h(\d)$')
    href_pattern = re.compile(r'^https?\:\/\/www\.mozilla\.org')

    # Manipulate the markup
    for section in soup.find_all('section'):
        level = 0
        header = soup.new_tag('header')
        div = soup.new_tag('div')

        section.insert(0, header)
        section.insert(1, div)

        # Append elements to <header> or <div>
        for tag in section.children:
            match = hn_pattern.match(tag.name)
            if match:
                header.append(tag)
                level = int(match.group(1))
            if tag.name == 'p':
                (header if level == 1 else div).append(tag)
            if tag.name in ['ul', 'hr']:
                div.append(tag)

        if level > 3:
            section.parent.div.append(section)

        # Remove empty <div>s
        if len(div.contents) == 0:
            div.extract()

    # Convert the site's full URLs to absolute paths
    for link in soup.find_all(href=href_pattern):
        link['href'] = href_pattern.sub('', link['href'])

    # Return the HTML flagment as a BeautifulSoup object
    return soup
开发者ID:Devil399,项目名称:bedrock,代码行数:55,代码来源:views.py


示例15: main

def main():
    base = os.path.abspath(os.path.dirname(__file__))
    index = os.path.join(base, "index.html.tmpl")
    readme = os.path.join(os.path.dirname(base), "README.md")

    templ = open(index).read()

    buf = StringIO.StringIO("rw")
    markdown.markdownFromFile(input=readme, output=buf)

    print templ.format(body=buf.getvalue())
开发者ID:AttackVectorLinux,项目名称:ghp-import,代码行数:11,代码来源:build.py


示例16: run

def run(): #pragma: no cover
    """Run Markdown from the command line."""

    # Parse options and adjust logging level if necessary
    options, logging_level = parse_options()
    if not options: sys.exit(2)
    logger.setLevel(logging_level)
    logger.addHandler(logging.StreamHandler())

    # Run
    markdown.markdownFromFile(**options)
开发者ID:9929105,项目名称:lini,代码行数:11,代码来源:__main__.py


示例17: parse_markdown

def parse_markdown(f, root):
    """
    This function parses a  markdown file.
    Args: 
        f = file name
        root = root folder for the given file
    """
    out = os.path.join(root, f[:f.rindex('.')] + '.html')
    inp = os.path.join(root, f)
    print 'parsing %s' % (f)
    markdown.markdownFromFile(input=inp, output=out)
开发者ID:andersoncardoso,项目名称:small_scripts,代码行数:11,代码来源:markdown_parser.py


示例18: process_markdown_files

def process_markdown_files():

    for markdown_file in os.listdir(input_dxtx_path):
        print("Markdown file = " + markdown_file)
        if markdown_file.endswith(".txt"):
            html_file = os.path.splitext(markdown_file)[0] + '.html'
            html_file_path = os.path.join(output_dxtx_path, html_file)
            markdown_file_path = os.path.join(input_dxtx_path, markdown_file)
            print("Parsing markdown file " + markdown_file_path + " and saving as as html file " + html_file_path)

            # use footnote extensions
            markdown.markdownFromFile(input=markdown_file_path, output=html_file_path,  extensions=['markdown.extensions.footnotes', 'markdown.extensions.tables'])
开发者ID:informaticslab,项目名称:lydia-py,代码行数:12,代码来源:mc-gen.py


示例19: on_modified

 def on_modified(self, event):
     markdown.markdownFromFile(
         input=os.path.join(args.path, INPUT),
         output=os.path.join(args.path, OUTPUT),
         encoding="iso-8859-1",
         extensions=[
             'markdown.extensions.tables',
             'markdown.extensions.sane_lists',
             'markdown.extensions.wikilinks',
             MarkdownInclude(configs={'base_path': args.path}),
             TocExtension(anchorlink=True),
             ])
开发者ID:diegolis,项目名称:ideasmanager,代码行数:12,代码来源:generate_book.py


示例20: render_markdown_from_file

def render_markdown_from_file(f):
    """Renders Markdown text to HTML.

    The Markdown text will be sanitized to prevent injecting custom HTML.
    It will also enable a few plugins for code highlighting and sane lists.
    """
    s = StringIO()
    markdownFromFile(input=f, output=s, **MARKDOWN_KWARGS)
    html = s.getvalue()
    s.close()

    return html
开发者ID:aaronmartin0303,项目名称:reviewboard,代码行数:12,代码来源:markdown_utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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