Git Product home page Git Product logo

markdown2pdf's Introduction

Markdown2PDF

Markdown2pdf is a command-line tool to convert markdown file into pdf, was originally designed for myself to create resume.

Building Status Code Health Downloads

Installation

To install Markdown2PDF you may need to install PDF convertion tool first,

Install Markdown2PDF by pip:

pip install markdown2pdf

Usage

You can use Markdown2PDF via simple command md2pdf:

md2pdf resume.md

You can also appoint a theme by argument --theme:

md2pdf resume.md --theme=github

Or, you can even using your self defined theme:

md2pdf resume.md --theme=path_to_style.css

By now, Markdown2PDF contains multi builtin themes:

  • github (from GitHub.Inc)
  • solarized-dark (from mixu/markdown-styles)
  • ghostwriter (from mixu/markdown-styles)

Trouble shooting

  1. ffi.h no such file or directory
apt-get install libffi-dev
  1. OSError: library not found: 'libcairo.so.2'

This means you need to get some requirements installed first, see this page: [WeasyPrint fails with error on OSX](Kozea/WeasyPrint#79).

markdown2pdf's People

Contributors

fernandezgonzalo avatar jfthuong avatar kxxoling avatar shipengtaov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

markdown2pdf's Issues

Facing TypeError while converting Markdown to PDF

kirans-thinkpad:~/Downloads$ sudo pip install markdown2pdf
The directory '/home/kiran/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/kiran/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: markdown2pdf in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: weasyprint in /usr/local/lib/python2.7/dist-packages (from markdown2pdf)
Requirement already satisfied: markdown2 in /usr/local/lib/python2.7/dist-packages (from markdown2pdf)
Requirement already satisfied: cffi>=0.6 in /home/deepcompute/.local/lib/python2.7/site-packages (from weasyprint->markdown2pdf)
Requirement already satisfied: CairoSVG<2.0.0,>=1.0.20; python_version < "3.0" in /usr/local/lib/python2.7/dist-packages (from weasyprint->markdown2pdf)
Requirement already satisfied: Pyphen>=0.8 in /usr/local/lib/python2.7/dist-packages (from weasyprint->markdown2pdf)
Requirement already satisfied: cssselect2>=0.1 in /usr/local/lib/python2.7/dist-packages (from weasyprint->markdown2pdf)
Requirement already satisfied: tinycss2>=0.5 in /usr/local/lib/python2.7/dist-packages (from weasyprint->markdown2pdf)
Requirement already satisfied: pdfrw>=0.4 in /usr/local/lib/python2.7/dist-packages (from weasyprint->markdown2pdf)
Requirement already satisfied: html5lib>=0.999999999 in /usr/local/lib/python2.7/dist-packages (from weasyprint->markdown2pdf)
Requirement already satisfied: cairocffi>=0.5 in /usr/local/lib/python2.7/dist-packages (from weasyprint->markdown2pdf)
Requirement already satisfied: pycparser in /home/deepcompute/.local/lib/python2.7/site-packages (from cffi>=0.6->weasyprint->markdown2pdf)
Requirement already satisfied: webencodings>=0.4 in /usr/local/lib/python2.7/dist-packages (from tinycss2>=0.5->weasyprint->markdown2pdf)
Requirement already satisfied: six>=1.9 in /usr/local/lib/python2.7/dist-packages (from html5lib>=0.999999999->weasyprint->markdown2pdf)
kirans-thinkpad:~/Downloads$ md2pdf README.md 
Traceback (most recent call last):
  File "/usr/local/bin/md2pdf", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/markdown2pdf/__init__.py", line 33, in main
    convert_md_2_pdf(**dict(args._get_kwargs()))
  File "/usr/local/lib/python2.7/dist-packages/markdown2pdf/__init__.py", line 23, in convert_md_2_pdf
    HTML(string=html).write_pdf(output)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/__init__.py", line 182, in write_pdf
    font_config=font_config).write_pdf(
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/__init__.py", line 143, in render
    font_config)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/document.py", line 326, in _render
    [Page(p, enable_hinting) for p in page_boxes],
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/__init__.py", line 55, in layout_document
    context, root_box, html, cascaded_styles, computed_styles))
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/pages.py", line 601, in make_all_pages
    context, root_box, page_type, resume_at, page_number)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/pages.py", line 520, in make_page
    positioned_boxes, positioned_boxes, adjoining_margins)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/blocks.py", line 83, in block_level_layout
    adjoining_margins)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/blocks.py", line 111, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/blocks.py", line 638, in block_container_layout
    adjoining_margins)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/blocks.py", line 83, in block_level_layout
    adjoining_margins)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/blocks.py", line 111, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/blocks.py", line 638, in block_container_layout
    adjoining_margins)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/blocks.py", line 83, in block_level_layout
    adjoining_margins)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/blocks.py", line 111, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/blocks.py", line 510, in block_container_layout
    for line, resume_at in lines_iterator:
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/inlines.py", line 51, in iter_line_boxes
    device_size, absolute_boxes, fixed_boxes, first_letter_style)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/inlines.py", line 108, in get_next_linebox
    waiting_floats, line_children=[])
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/inlines.py", line 727, in split_inline_box
    line_placeholders, waiting_floats, line_children)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/inlines.py", line 600, in split_inline_level
    waiting_floats, line_children)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/inlines.py", line 727, in split_inline_box
    line_placeholders, waiting_floats, line_children)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/inlines.py", line 600, in split_inline_level
    waiting_floats, line_children)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/layout/inlines.py", line 839, in split_inline_box
    child_resume_at[0] + current_skip,
TypeError: 'NoneType' object has no attribute '__getitem__'

Convert error in some case

Work on ubuntu16.04.python2.7, markdown2pdf install pip install markdown2pdf.
Covert markdown script md2pdf test.md

## title1

### title2
test statement.
* first point
  + aaaaaaaaaaaaaaaaaaaaaaaaa
  + bbbbbbbbbbbbbbbbbbbbbbbbb
* second point
  + ccccccccccccccccccccccccc
  + ddddddddddddddddddddddddd
  + fffffffffffffffffffffffff

and get
aa
Then remove test statement. from the script,conversion is correct.
Is there something wrong?

Deprecated?

The main page says

[Deprecated] A command line tool to convert markdown file to pdf.

Is this tool no longer supported? Is there a recommended replacement?

SyntaxError: Missing parentheses in call to 'print'. Did you mean print(css_file)

I just got the following error when use the markdown2pdf.

 [reuber@stormy hive-api]$ md2pdf ENDPOINTS.md --theme=github
Traceback (most recent call last):
  File "/home/reuber/envs/hive-api/bin/md2pdf", line 11, in <module>
    load_entry_point('Markdown2PDF==0.1.4', 'console_scripts', 'md2pdf')()
  File "/home/reuber/envs/hive-api/lib64/python3.8/site-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/reuber/envs/hive-api/lib64/python3.8/site-packages/pkg_resources/__init__.py", line 2859, in load_entry_point
    return ep.load()
  File "/home/reuber/envs/hive-api/lib64/python3.8/site-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/home/reuber/envs/hive-api/lib64/python3.8/site-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/reuber/envs/hive-api/lib64/python3.8/site-packages/markdown2pdf/__init__.py", line 20
    print css_file
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(css_file)?

It' seems the pypi version is an old version.

I think I fixed a tiny pip install bug

With no cffi in requirements.txt, just starting markdown2pdf installation with pip install,

these error will arise, like

        replace_conflicting=replace_conflicting
      File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 1060, in best_match
        return self.obtain(req, installer)
      File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 1072, in obtain
        return installer(requirement)
      File "/usr/local/lib/python3.5/dist-packages/setuptools/dist.py", line 581, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/local/lib/python3.5/dist-packages/setuptools/command/easy_install.py", line 670, in easy_install
        raise DistutilsError(msg)
    distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('cffi>=1.1.0')

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-f8j_a507/cairocffi/

merging it helps, I think ~

Script fails

There are no paentheses in init.py file, line 20:
print css_file
I use Python3 and downloaded package using pip3 as well

Add license file to project

I would love to use this lib on the project I'm working on right now with my company, but I can only do so if the code is properly licensed. Can you please add a license file to your project? Here is an example.

Thanks.

"Command python setup.py egg_info" failed with error code 1 in...

Encountering an issue when using "pip install markdown2pdf" in that I receive the error "Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3d/s2kz5njn5713qqz7l5wh1mnr0000gp/T/pip-build-VgE7ie/cairocffi/." I searched all over the place, but I cannot find a solution. Just looking for some feedback as to what the problem could be. I have also attached a screenshot of the console so that you can see the error as well. Thanks in advance!
screen shot 2016-06-28 at 9 55 03 am

UnicodeDecodeError

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 49: ordinal not in range(128)

python 3 doesn't supported?

Traceback (most recent call last):
  File "./env/bin/md2pdf", line 7, in <module>
    from markdown2pdf import main
  File "/home/alp/wrk/visyond.com/repos/environment_root/util/checkbranch/env/lib/python3.6/site-packages/markdown2pdf/__init__.py", line 20
    print css_file
                 ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(print css_file)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.