alvinwan / TexSoup

fault-tolerant Python3 package for searching, navigating, and modifying LaTeX documents
https://texsoup.alvinwan.com
BSD 2-Clause "Simplified" License
290 stars 43 forks source link

It's contents not content, and all is only on expr not on nodes #114

Closed ivanistheone closed 4 years ago

ivanistheone commented 4 years ago

I noticed these two small typos in the docs.


Also, I noticed a surprising aspect of .contents including optional args of environments, e.g.

>>> figs = soup.find_all('figure')
>>> fig = figs[0]
>>> fig
\begin{figure}[H]
    \centering
    \includegraphics[width=0.4\textwidth]{figures/vectors/vector_components.pdf}
    \vspace{-2mm}
    \caption{   The vector $\vec{v}=(3,2)$ is an arrow in the Cartesian plane.
            The horizontal component of $\vec{v}$ is $v_x=3$
            and the vertical component  is $v_y=2$.}
    \label{fig:vector_components}
\end{figure}

>>> fig.contents
['H',
 \centering,
 \includegraphics[width=0.4\textwidth]{figures/vectors/vector_components.pdf},
 \vspace{-2mm},
 \caption{  The vector $\vec{v}=(3,2)$ is an arrow in the Cartesian plane.
            The horizontal component of $\vec{v}$ is $v_x=3$
            and the vertical component  is $v_y=2$.},
 \label{fig:vector_components}]

I would have expected the "[H]" not to be part of the content stream since it is logically part of the environment opening tag, but as you can above the first item in contents is an H of type TexSoup.utils.Token.

Note figure-environment has correctly parsed the [H] optional arg:

>>> fig.args
[BracketGroup('H')]

so wondering why if it should be removed from the .contents stream. Let me know if this is as intended, or if I should file a bug.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling e627903065b5ed73902829c4ea03c255ab5956c6 on minireference:docs_typo_fix into e9e89cfe21a6221f9966bee9a7c77548bf4b689e on alvinwan:master.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling e627903065b5ed73902829c4ea03c255ab5956c6 on minireference:docs_typo_fix into e9e89cfe21a6221f9966bee9a7c77548bf4b689e on alvinwan:master.

alvinwan commented 4 years ago

@ivanistheone Thanks for the PR! To your points: