Skip to content

Support LaTeX minted python blocks #34

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

Merged
merged 2 commits into from
Dec 6, 2019
Merged

Conversation

peterjc
Copy link
Contributor

@peterjc peterjc commented Dec 6, 2019

Using \begin{minted}{python} environments is one of the most popular ways to write literal blocks of Python code in LaTeX with syntax colouring.

This pull request was written and tested on the Biopython Tutorial, currently written in LaTeX using minted blocks for python code (and more code using pycon but that needs #8 to work), see e.g.
https://github.com/biopython/biopython/blob/biopython-175/Doc/Tutorial.tex

We previously used \verbatim blocks in LaTeX, but these are not specific to Python code and so should not be formatted with black (same issue with RST and :: blocks, #21): biopython/biopython@98e84b7

The other popular convention for syntax coloured Python code within LaTeX is \begin{listing}[language=Python] and it would be relatively straightforward to cover that as well.

These are one of the most popular ways to write
literal blocks of Python code in LaTeX with syntax
colouring.
peterjc added a commit to peterjc/biopython that referenced this pull request Dec 6, 2019
This does not cover the pycon (python console) aka
doctest style Python snippets in the Tutorial.

$ python blacken_docs.py ../biopython/Doc/Tutorial/chapter_*.tex
../biopython/Doc/Tutorial/chapter_advanced.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_align.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_appendix.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_cluster.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_cookbook.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_entrez.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_graphics.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_kegg.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_phylo.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_popgen.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_quick_start.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_seq_annot.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_seqio.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_testing.tex: Rewriting...

Note that the black default line length of 88 seems to
be OK for the PDF Tutorial output.

See adamchainz/blacken-docs#34
Copy link
Contributor

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks!

@asottile asottile merged commit 2c250f8 into adamchainz:master Dec 6, 2019
@asottile
Copy link
Contributor

asottile commented Dec 6, 2019

thanks!

@asottile
Copy link
Contributor

asottile commented Dec 6, 2019

released as 1.4.0

@peterjc peterjc deleted the minted branch December 6, 2019 16:57
peterjc added a commit to biopython/biopython that referenced this pull request Dec 11, 2019
This does not cover the pycon (python console) aka
doctest style Python snippets in the Tutorial.

$ python blacken_docs.py ../biopython/Doc/Tutorial/chapter_*.tex
../biopython/Doc/Tutorial/chapter_advanced.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_align.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_appendix.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_cluster.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_cookbook.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_entrez.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_graphics.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_kegg.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_phylo.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_popgen.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_quick_start.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_seq_annot.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_seqio.tex: Rewriting...
../biopython/Doc/Tutorial/chapter_testing.tex: Rewriting...

Note that the black default line length of 88 seems to
be OK for the PDF Tutorial output.

See adamchainz/blacken-docs#34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants