Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def generate_html_path(markdown_path, html_path):
if not exists(dirname(html_path)):
os.makedirs(dirname(html_path))
html = markdown2.markdown_path(markdown_path)
codecs.open(html_path, 'w', 'utf-8').write(html)
def showAbout(self):
"""Show subwindow with about info."""
html = markdown2.markdown_path(
scctool.settings.getResFile("about.md"))
html = html.replace("%VERSION%", scctool.__version__)
if(not scctool.__new_version__):
new_version = _("StarCraft Casting Tool is up to date.")
else:
new_version = _("The new version {} is available!").format(
scctool.__latest_version__)
html = html.replace('%NEW_VERSION%', new_version)
# use self as parent here
QMessageBox.about(
self, _("StarCraft Casting Tool - About"), html)
def markdown_render(filename):
html_text = markdown_path(PAGES_PATH + filename)
return html_text
arguments:
gh_repo_folder -- the repo local folder path
returns:
description -- html description
"""
path = '{}/{}'.format(gh_repo_folder,'README.md')
path3 = '{}/{}'.format(gh_repo_folder,'readme.md')
path2 = '{}/{}'.format(gh_repo_folder,'readme.txt')
description = ''
if os.path.exists(path):
description = markdown_path(path)
description = description.replace('\n','')
elif os.path.exists(path3):
description = markdown_path(path3)
description = description.replace('\n','')
elif os.path.exists(path2):
with open(path2,'r') as f:
description = f.readlines()
description =' '.join(description)
return description
def main(argv=None):
# Parse command line arguments
arguments = docopt(
__doc__,
version='md2pdf %s' % __version__)
# Paths
md_file_path = arguments.get('INPUT.MD')
pdf_file_path = arguments.get('OUTPUT.PDF')
css_file_path = arguments.get('--css', None)
# Convert markdown to html
raw_html = markdown_path(md_file_path)
# Weasyprint HTML object
html = HTML(string=raw_html)
# 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 1
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(
"_layout.html",
active_page="help",
page_slug=page_slug,
help_html=render_template_string(html),
)