adamchainz/blacken-docs

Issue with atypical Latex indentation

peterjc opened this issue · 2 comments

e.g. https://github.com/peterjc/biopython/blob/biopython-175/Doc/Tutorial/chapter_phenotype.tex

Reduced to a smaller test case, note the inconsistent indentation of lines 4 and 6 (which LaTeX does not care about):

\begin{description}
  \item[Well identifier]
    If you know the well identifier (row + column identifiers) you can access the desired well directly.
\begin{minted}{pycon}
    >>> record["A02"]
    \end{minted}

  \item[Well plate coordinates]
    The same well can be retrieved by using the row and columns numbers (0-based index).

%doctest examples lib:numpy
\begin{minted}{pycon}
>>> from Bio import phenotype
>>> record = list(phenotype.parse("Plates.csv", "pm-csv"))[-1]
>>> print(record[0, 1].id)
A02
\end{minted}

more text here...

\end{description}

The output:

\begin{description}
  \item[Well identifier]
    If you know the well identifier (row + column identifiers) you can access the desired well directly.
\begin{minted}{pycon}
>>> record["A02"]
\end{minted}

tem[Well plate coordinates]
The same well can be retrieved by using the row and columns numbers (0-based index).

test examples lib:numpy
in{minted}{pycon}
>>> from Bio import phenotype
>>> record = list(phenotype.parse("Plates.csv", "pm-csv"))[-1]
>>> print(record[0, 1].id)

\end{minted}

more text here...

\end{description}

Notice line 8 onwards (after the end of the code snippet) has lost the first few characters, it should still start \item

I suspect the issue is the two code blocks with text in between being treated as one code block?

unless you're planning on working on this -- I don't think this will be fixed (looks like you added the latex implementation)

I suspected you might say that - I'm not sure without digging into it if this is an oversight in just the recently added \begin{minted}{pycon} regex, or all the LaTeX patterns in general. LaTeX can be frustratingly flexible on somethings (like the white space indentation here) while incredibly precise on others.

I've been off work sick this week, and am unlikely to look any further at this in the next week or so.