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

Python markdown2.markdown_path函数代码示例

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

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



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

示例1: GET

	def GET(self,page):
		cwd = os.getcwd()
		if page == '':
			# Main api docs page
			htmldoc = markdown2.markdown_path(cwd+'/templates/main.md')
			return templates.docs(htmldoc)
		else:
			# Politician api docs page
			htmldoc = markdown2.markdown_path(cwd+'/templates/'+page+'.md')
			return templates.docs(htmldoc)
开发者ID:HengeSense,项目名称:ALEC_api,代码行数:10,代码来源:api.py


示例2: load_pagefile

def load_pagefile(name):
	if os.path.isdir(flatfiles_path+name):
		flatfiles = os.listdir(flatfiles_path+name)
		if 'index' in flatfiles:
			return markdown2.markdown_path(flatfiles_path+name+'/index')
		else:
			return False
	else:
		if os.path.isfile(flatfiles_path+name):
			return markdown2.markdown_path(flatfiles_path+name)
		else:
			return False
开发者ID:mattyg,项目名称:GitPage,代码行数:12,代码来源:index.py


示例3: index

def index():
    """
    The landing page.
    """

    try:
        html = markdown2.markdown_path(BASE_DIR + '/index.md', extras=["metadata"])

        items = []

        # Find the folders (categories) in the folder sites
        for dirname in os.listdir(SITES_DIR):
            items.append(dirname)

        metadata = html.metadata
        if 'template' in metadata.keys():
            template = metadata['template']
        else:
            template = 'templates/index.html'

        render_data = metadata.copy()
        render_data[u'body'] = html
        render_data[u'items'] = items

        rendered = jenv.get_template(template).render(render_data)
        return rendered

    except IOError as e:
        print(e)
        return render_template('404.html'), 404
开发者ID:jherrlin,项目名称:Zappa-CMS,代码行数:30,代码来源:zappa_cms.py


示例4: md2pdf

def md2pdf(pdf_file_path, md_content=None, md_file_path=None,
           css_file_path=None, base_url=None):
    """
    Convert markdown file to pdf with styles
    """

    # Convert markdown to html
    raw_html = ""
    extras = ["cuddled-lists"]
    if md_file_path:
        raw_html = markdown_path(md_file_path, extras=extras)
    elif md_content:
        raw_html = markdown(md_content, extras=extras)

    if not len(raw_html):
        raise ValidationError('Input markdown seems empty')

    # Weasyprint HTML object
    html = HTML(string=raw_html, base_url=base_url)

    # Get styles
    css = []
    if css_file_path:
        css.append(CSS(filename=css_file_path))

    # Generate PDF
    html.write_pdf(pdf_file_path, stylesheets=css)

    return
开发者ID:krichprollsch,项目名称:md2pdf,代码行数:29,代码来源:core.py


示例5: item

def item(category, item_slug):
    """
    A single specific item.

    """

    try:
        path = category + '/' + item_slug + '.md'
        html = markdown2.markdown_path(path, extras=["metadata"])

        metadata = html.metadata
        if 'template' in metadata.keys():
            template = metadata['template']
        else:
            template = 'templates/item.html'

        render_data = metadata.copy()
        render_data[u'body'] = html
        render_data[u'category'] = category
        render_data[u'item_slug'] = item_slug

        rendered = jenv.get_template(template).render(render_data)
        return rendered

    except IOError as e:
        return render_template('404.html'), 404
开发者ID:Miserlou,项目名称:Zappa-CMS,代码行数:26,代码来源:zappa_cms.py


示例6: md_to_html

def md_to_html(ifile,ofile):
    tpl=u'''
    <html>
	<head>
	    <meta charset="utf-8">
	    <meta name="viewport" content="width=device-width">
            <link rel="stylesheet" href="./{css}">
            <link rel="stylesheet" href="./{code_css}">
            <title>{title}</title>
	</head>
	<body class="publisher">
            <div class="container">
                <article id="preview-contents">
	        {body} 
                </article>
            </div>
	</body>
    </html>
    '''
    css='agroup.css'
    code_css='github.css'
    title=''
    reg=re.compile(r'^#\s*([^#]+)')
    m=reg.search(file(ifile,'r').read())
    if m:
        title=m.group(1).decode('utf8')
    body=markdown2.markdown_path(ifile,extras=[
        "fenced-code-blocks",
        "tables",
        "toc",
    ])
    html=tpl.format(**locals())
    file(ofile,'w').write(html.encode('utf8'))
开发者ID:vindurriel,项目名称:vindurriel.github.com,代码行数:33,代码来源:md.py


示例7: populateWords

def populateWords():
    for category in twOrder:
        terms[category] = {}
        dir = os.path.join(twRoot, 'content', category)
        files = glob(os.path.join(dir, '*.md'))
        ta_links = re.compile(
            '"https://git.door43.org/Door43/(en-ta-([^\/"]+?)-([^\/"]+?))/src/master/content/([^\/"]+?).md"')
        for f in files:
            term = os.path.splitext(os.path.basename(f))[0]
            content = markdown2.markdown_path(f)
            content = u'<div id="{0}-{1}" class="word">'.format(category, term)+content+u'</div>'
            parts = ta_links.split(content)
            if len(parts) == 6 and parts[1] in taManualUrls:
                content = parts[0]+'"{0}/{1}#{2}_{3}_{4}"'.format(taUrl, taManualUrls[parts[1]], parts[3], parts[2], parts[4])+parts[5]
            content = re.sub(r'href="\.\.\/([^\/"]+)\/([^"]+)\.md"', r'href="#\1-\2"', content)
            soup = BeautifulSoup(content)
            if soup.h1:
                title = soup.h1.text
            else:
                title = term
                print title
            for i in reversed(range(1, 4)):
                for h in soup.select('h{0}'.format(i)):
                    h.name = 'h{0}'.format(i+1)
            content = str(soup.div)
            word = TwTerm(term, title, content)
            terms[category][term] = word
开发者ID:richmahn,项目名称:tools,代码行数:27,代码来源:md_to_html_export.py


示例8: convert_mds

def convert_mds(source, target, link, yaml):
    listing = os.listdir(source)
    for infile in listing:
	if infile[0] != '.':
	    filepath = os.path.join(source, infile)
	    filename, fileext = os.path.splitext(infile)
	    
	    outfilepath = os.path.join(target, "{}.html".format(filename))
	    outlink =  os.path.join(link, "{}.html".format(filename))
	    outfile = open(outfilepath, 'w')
	    output = markdown_path(filepath, extras=['metadata', 'fenced-code-blocks', 'tables'])
	    
	    if yaml:
		gather_metadata(output.metadata, outlink)
		content = '''
{{% extends "base.html" %}}
{{% block content %}}
<span class="label label-primary">{}</span>
<span class="label label-info">{}</span>
{}
{{% endblock %}}
'''.format(output.metadata['date'], output.metadata['tag'], output)

	    else:			
		content = '''
{{% extends "base.html" %}}
{{% block content %}}
{}
{{% endblock %}}
'''.format(output)
	    outfile.write(content)
	    outfile.close()
开发者ID:bdevorem,项目名称:bashfulbytes,代码行数:32,代码来源:gen.py


示例9: help_page

def help_page(page_slug='_index'):
    if page_slug not in app.config['HELP_PAGES'].keys():
        abort(404)
    html = markdown2.markdown_path(
        os.path.join(app.config['HELP_DIR'], page_slug + '.md'),
        extras=["metadata", "fenced-code-blocks", "tables"])
    return render_template('help.html', help_html=html, page_slug=page_slug)
开发者ID:fudanchii,项目名称:fava,代码行数:7,代码来源:application.py


示例10: convert_md_2_pdf

def convert_md_2_pdf(filepath, output=None, theme=None, codecss=None):
    BASE_DIR = os.path.abspath(os.path.dirname(__file__))
    html = markdown_path(filepath, extras=["code-friendly", "fenced-code-blocks"])
    css_file_list = []
    if output and os.path.isdir(output):
        output = os.path.join(output, '.'.join([os.path.basename(filepath).rsplit('.', 1)[0], 'pdf']))
    elif output is None:
        output = '.'.join([filepath.rsplit('.', 1)[0], 'pdf'])
    if theme is not None:
        css_file = theme
        if not os.path.exists(css_file):
            css_file = os.path.join(BASE_DIR, 'themes/'+theme+'.css')
        print 'theme_css:', css_file
        css_file_list.append(css_file)
        # HTML(string=html).write_pdf(output, stylesheets=[css_file])
    
    if codecss is not None:
        css_file = codecss
        if not os.path.exists(css_file):
            css_file = os.path.join(BASE_DIR, 'pygments-css/'+codecss+'.css')
        print 'code_css:', css_file
        css_file_list.append(css_file)

    print 'output file:', output
    if css_file_list:
        HTML(string=html).write_pdf(output, stylesheets=css_file_list)
    else:
        HTML(string=html).write_pdf(output)
开发者ID:leafsummer,项目名称:common_tools,代码行数:28,代码来源:md2pdf.py


示例11: package_bundle

def package_bundle(bundle_path, zip_parent):
    """Package a bundle and create the appcast, input:
    
       * A built bundle with Contents/Info.plist, must have SUFeedURL
         for Sparkle.
       * ~/.ssh/<bundleNameInLowercase>.private.pem to sign the zip"""

    plist = plistlib.readPlist("%s/Contents/Info.plist" % bundle_path)
    bundle_name = plist["CFBundleName"]
    appcast_url = plist["SUFeedURL"]
    bundle_version = plist["CFBundleVersion"]
    zip = "%s-%s.zip" % (bundle_name, bundle_version)
    zip_url = "%s/%s" % (zip_parent, zip)
    priv_key = os.path.expanduser("~/.ssh/%s.private.pem" % bundle_name.lower())
    date = time.strftime("%a, %d %b %Y %H:%M:%S %z")

    print "[PACK] Building %s..." % zip

    cwd = os.getcwd()
    os.chdir(os.path.dirname(bundle_path))
    os.system("zip -qry %s/%s %s" % (cwd, zip, os.path.basename(bundle_path)))
    os.chdir(cwd)

    print "[PACK] Signing %s..." % zip
    signed = commands.getoutput(
        'openssl dgst -sha1 -binary < "%s" | '
        'openssl dgst -dss1 -sign "%s" | '
        "openssl enc -base64" % (zip, priv_key)
    )

    env = Environment(loader=FileSystemLoader(sys.path[0]))
    template = env.get_template("appcast.template.xml")

    for lang in ["en", "zh_CN", "zh_TW"]:
        if lang == "en":
            suffix = ""
        else:
            suffix = ".%s" % lang
        relnotes = markdown2.markdown_path("Changelog%s.markdown" % suffix)
        appcast = "%s%s.xml" % (bundle_name, suffix)
        print "[PACK] Generating %s..." % appcast
        output = open(appcast, "w")

        output.write(
            template.render(
                appName=bundle_name,
                link=appcast_url,
                relNotes=relnotes,
                url=zip_url,
                date=date,
                version=bundle_version,
                length=os.path.getsize(zip),
                signed=signed,
            ).encode("utf-8")
        )

        output.close()

    print "Done! Please publish %s to %s." % (zip, zip_url)
开发者ID:Rayer,项目名称:nally,代码行数:59,代码来源:package.py


示例12: home

def home(request):
    markup = markdown2.markdown_path(README_PATH)
    markup = fix_markup(markup)
    return render_to_response('home.html',
            { 
                'markup': markup,
            },
            RequestContext(request))
开发者ID:phrawzty,项目名称:mozpackager,代码行数:8,代码来源:views.py


示例13: help_page

def help_page(page_slug='_index'):
    if page_slug not in app.config['HELP_PAGES']:
        abort(404)
    html = markdown2.markdown_path(
        os.path.join(app.config['HELP_DIR'], page_slug + '.md'),
        extras=['fenced-code-blocks', 'tables'])
    return render_template('help.html', page_slug=page_slug,
                           help_html=render_template_string(html))
开发者ID:aumayr,项目名称:fava,代码行数:8,代码来源:application.py


示例14: convert

def convert():
    print "Converting"
    in_file = TEST_DIR + "/" + IN_FILE
    out_file = OUT_DIR + "/" + OUT_FILE
    html = markdown2.markdown_path(in_file)
    header = read_file(HEADER)
    footer = read_file(FOOTER)
    write_file(out_file, header + html + footer )
开发者ID:mohammadthalif,项目名称:staticblog,代码行数:8,代码来源:staticblog.py


示例15: discover_help_pages

def discover_help_pages():
    app.config['HELP_PAGES'] = {}
    for page in os.listdir(app.config['HELP_DIR']):
        html = markdown2.markdown_path(
            os.path.join(app.config['HELP_DIR'], page), extras=["metadata"])
        slug = os.path.splitext(os.path.basename(page))[0]
        title = html.metadata['title']

        app.config['HELP_PAGES'][slug] = title
开发者ID:fudanchii,项目名称:fava,代码行数:9,代码来源:application.py


示例16: category

def category(category):
    """
    Categories of items.

    Essentially a 'directory listing' page. 

    Returns to the items to the 'index'.

    """

    try:

        # First do the items
        items = []
        for filename in os.listdir(category):
            if 'index.md' in filename: 
                continue
            item = markdown2.markdown_path(category + '/' + filename, extras=["metadata"])
            item.metadata['slug'] = filename.split('/')[-1].replace('.md', '')
            items.append(item)

        # Then do the index
        path = category + '/index.md'
        html = markdown2.markdown_path(path, extras=["metadata"])

        metadata = html.metadata
        if 'template' in metadata.keys():
            template = metadata['template']
        else:
            template = 'templates/category.html'

        render_data = metadata.copy()
        render_data[u'body'] = html
        render_data[u'items'] = items
        render_data[u'category'] = category

        rendered = jenv.get_template(template).render(render_data)
        return rendered

    except IOError as e:
        print(e)
        return render_template('404.html'), 404
开发者ID:Miserlou,项目名称:Zappa-CMS,代码行数:42,代码来源:zappa_cms.py


示例17: help_page

def help_page(page_slug='_index'):
    """Fava's included documentation."""
    if page_slug not in app.config['HELP_PAGES']:
        abort(404)
    html = markdown2.markdown_path(
        os.path.join(resource_path('help'), page_slug + '.md'),
        extras=['fenced-code-blocks', 'tables'])
    return render_template(
        'help.html',
        page_slug=page_slug,
        help_html=render_template_string(html))
开发者ID:adamgibbins,项目名称:fava,代码行数:11,代码来源:application.py


示例18: list_help_pages

def list_help_pages():
    help_pages = []

    for page in os.listdir(app.docs_dir):
        html = markdown2.markdown_path(os.path.join(app.docs_dir, page),
                                       extras=["metadata"])
        slug = "help/{}".format(os.path.splitext(os.path.basename(page))[0])
        title = html.metadata['title']

        help_pages.append((slug, title, None))

    return sorted(help_pages, key=lambda x: x[1] == 'Index', reverse=True)
开发者ID:miaoluda,项目名称:fava,代码行数:12,代码来源:application.py


示例19: processmkd

def processmkd(filename):
    theHead = ''
    thehtml = markdown2.markdown_path(filename)
    theTitle = unicode(filename,"utf-8")
    fileHandle = open(filename+'.html', "w")
    theHead = '<!DOCTYPE html>'
    theHead += '<html><head><meta charset="utf-8"/><title>' + theTitle + '</title><link href="demo.css" type="text/css" rel="stylesheet"/></head><body>'
    theHead += thehtml
    theHead += '</body></html>\n'
    theHTML =  theHead.encode('utf-8')
    fileHandle.write(theHTML)
    fileHandle.close()
开发者ID:amdgigabyte,项目名称:python-tools,代码行数:12,代码来源:mark2html.py


示例20: md_viewer

def md_viewer(session, pad, mode):
    with open('config.json', 'r') as f:
        published = json.load(f)['published']
    if pad in published or session.get('in'):
        path = 'pads/{0}.md'.format(pad)
        if mode == 'html':
            return markdown2.markdown_path(path)
        else:
            with open(path, 'r') as f:
                bottle.response.content_type = 'text/plain'
                return f.read()
    else:
        bottle.abort(404)
开发者ID:fallingduck,项目名称:strongpad,代码行数:13,代码来源:server.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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