Skip to content

Instantly share code, notes, and snippets.

@petereichinger
Forked from Beyamor/markdown-to-pdf.py
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save petereichinger/c4715f7b7cd2c4af7ed4 to your computer and use it in GitHub Desktop.

Select an option

Save petereichinger/c4715f7b7cd2c4af7ed4 to your computer and use it in GitHub Desktop.

Revisions

  1. petereichinger revised this gist Dec 3, 2014. 1 changed file with 11 additions and 7 deletions.
    18 changes: 11 additions & 7 deletions markdown-to-pdf.py
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,28 @@
    import os, sys

    markdown_name = sys.argv[1]
    name = markdown_name.split(".")[0]
    latex_name = name + ".tex"

    os.system("pandoc -f markdown -t latex %s -o %s" % (markdown_name, latex_name))

    with open(latex_name, "r") as latex_file:
    latex_content = latex_file.read()

    latex_content = """
    \documentclass[a4paper,12pt,parskip=full]{scrartcl}
    \usepackage{setspace}
    \usepackage{graphicx}
    \usepackage{hyperref}
    \usepackage{longtable}
    \usepackage{booktabs}
    \doublespacing
    \\begin{document}
    %s
    \end{document}
    """ % (latex_content)

    with open(latex_name, "w") as latex_file:
    latex_file.write(latex_content)

    os.system("pdflatex %s" % (latex_name))
    os.system("pdflatex %s" % (latex_name))
  2. @Beyamor Beyamor created this gist Aug 6, 2013.
    24 changes: 24 additions & 0 deletions markdown-to-pdf.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    import os, sys

    markdown_name = sys.argv[1]
    name = markdown_name.split(".")[0]
    latex_name = name + ".tex"

    os.system("pandoc -f markdown -t latex %s -o %s" % (markdown_name, latex_name))

    with open(latex_name, "r") as latex_file:
    latex_content = latex_file.read()

    latex_content = """
    \documentclass[a4paper,12pt,parskip=full]{scrartcl}
    \usepackage{setspace}
    \doublespacing
    \\begin{document}
    %s
    \end{document}
    """ % (latex_content)

    with open(latex_name, "w") as latex_file:
    latex_file.write(latex_content)

    os.system("pdflatex %s" % (latex_name))