Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support .. include:: file.py with :code: python #1187

Open
habamax opened this issue Feb 19, 2024 · 1 comment
Open

support .. include:: file.py with :code: python #1187

habamax opened this issue Feb 19, 2024 · 1 comment

Comments

@habamax
Copy link

habamax commented Feb 19, 2024

Currently if I include a file using:

test.rst

Include Example
===============

.. include:: test.py
  :code: python

test.py

def hello_world():
    """Doc string"""
    print("Hello World!")

Result using rst2html is

image

Result of rst2pdf is

image

Description of problem

I know there is

.. code-block:: python
  :include: test.py

That works just fine

image

but unfortunately docutils doesn't support code-block.

For now I just have two versions for each included file in my documents and do bulk comment/uncomment depending on media type I am to export to.

It would be really nice if rst2pdf could work with .. include:: ...\n :code: lang as well.

🖥 Versions

python -V: 3.11.2

pip freeze | grep rst2pdf: 0.101

pip freeze | grep reportlab: 4.1.0

Which operating system are you using?

Debian bookworm

@lornajane
Copy link
Contributor

Thanks for the suggestion, I'd be very happy to review pull requests on this if anyone has time to work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants