rst2pdf / rst2pdf.github.io

Website for the rst2pdf project "use a text editor, make a PDF"

Home Page:https://rst2pdf.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add your favorite code example to our syntax highlight doc

lornajane opened this issue · comments

We have an example project with some code in it, showing off syntax highlight (see https://rst2pdf.org/examples under "Code Samples" ) and it is also useful for testing different pygments themes.

If you write a programming language that is not included in the doc, we would love a PR of 10-30 lines of code in a new section to show it off (and check it works!)

I've added a new code example to the doc and when I run Jekyll I can see the change in the code1.rst file, but I'm not 100% sure how to generate the PDF to check what it looks like 😅 .

Don't worry. If you want to see it, there's an example command with the sample PDF https://rst2pdf.org/examples#code-samples - something like rst2pdf code1.rst will give you some default-styled output.

Hmm... I can't seem to get the rst2pdf command to work. I'm running Python 3.8.1 and I installed rst2pdf from GitHub following the instructions (I'm using a Mac). That all went OK but when I run the rst2pdf command I get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/rst2pdf", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3241, in <module>
    @_call_aside
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3225, in _call_aside
    f(*args, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'jinja2' distribution was not found and is required by rst2pdf

Look like it's something to do with with my Python config. Although I'm running v3.8.1, it seems like it's trying to use v2.7.

Apologies for being a newbie. I've used LaTeX and Pandoc before to generate PDFs, but wanted to see if I could get this 'new' way to work!

Scratch that. Managed to fix it using sudo python3 setup.py install instead of sudo python setup.py install and it now works a treat! I'll try and add the PDF to the original PR.

I've added the PDF now to #24. Loving this tool!

I notice there's a bit of discrepancy in the installation instructions in the README compared to those on https://rst2pdf.org/. Would it be useful to update these to make them more consistent? Perhaps the sudo python3 setup.py install command, which is where I came unstuck, could be added too? Happy to help out if you think it's necessary.

Yes please go ahead and update our install instructions. Not every platform uses python3 as their command but we should definitely note it as an option. That would be great, thanks!

Sure! I've added a note here about python3: #25. I'll have a go at adding something to the README too when I get a chance.