-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixes #106 version bump request * finished basic guides (added modification) * added crazy opt arg test from plastex/plastex#129
- Loading branch information
Showing
5 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,95 @@ | ||
Modification | ||
=================================== | ||
|
||
.. note:: This guide is coming soon. In the meantime, please see the package | ||
reference for a :class:`TexSoup.data.TexNode`. | ||
You can also modify the document using the TexSoup tree, then export the changes | ||
back to a :math:`\LaTeX` file. | ||
|
||
Commands | ||
----------------------------------- | ||
|
||
As mentioned in :ref:`page-soup`, you can change commands and their arguments. | ||
|
||
>>> soup = TexSoup(r'I am \textbf{\large Large and bold}') | ||
>>> cmd = soup.textbf | ||
>>> cmd.name = 'textit' | ||
>>> cmd | ||
\textit{\large Large and bold} | ||
|
||
You can set :code:`.string` for any single-argument command (e.g., :code:`\section`). | ||
|
||
>>> cmd.string = 'corgis are the best' | ||
>>> cmd | ||
\textit{corgis are the best} | ||
|
||
You can do the same for any command in math mode. | ||
|
||
>>> soup2 = TexSoup(r'$$\textrm{math}\sum$$') | ||
>>> soup2.textrm.string = 'not math' | ||
>>> soup2 | ||
$$\textrm{not math}\sum$$ | ||
|
||
You can also remove any command in-place, by calling :code:`.delete` on it. | ||
|
||
>>> soup2.textrm.delete() | ||
>>> soup2 | ||
$$\sum$$ | ||
|
||
Arguments | ||
----------------------------------- | ||
|
||
You can modify arguments just as you would a list. | ||
|
||
>>> cmd.args.append('{moar}') | ||
>>> cmd | ||
\textit{corgis are the best}{moar} | ||
>>> cmd.args.remove('{moar}') | ||
>>> cmd | ||
\textit{corgis are the best} | ||
>>> cmd.args.extend(['[moar]', '{crazy}']) | ||
\textit{corgis are the best}[moar]{crazy} | ||
>>> cmd.args = cmd.args[:2] | ||
>>> cmd | ||
\textit{corgis are the best}[moar] | ||
|
||
Use the argument's :code:`.string` attribute to modify the argument's contents. | ||
|
||
>>> cmd.args[0].string = 'no' | ||
>>> cmd | ||
\textit{no}[moar] | ||
|
||
Environments | ||
----------------------------------- | ||
|
||
Use the :code:`.string` attribute to modify any environment with only text content | ||
(i.e., a verbatim or math environment). | ||
|
||
>>> soup = TexSoup(r'\begin{verbatim}Huehue\end{verbatim}') | ||
>>> soup.verbatim.string = 'HUEHUE' | ||
>>> soup | ||
\begin{verbatim}HUEHUE\end{verbatim} | ||
>>> soup = TexSoup(r'$$\text{math}$$') | ||
>>> soup.text.string = '' | ||
|
||
You can add to an environment's contents using list-like operations, like | ||
:code:`.append`, :code:`.remove`, :code:`.insert`, and :code:`.extend`. | ||
|
||
>>> from TexSoup import TexSoup | ||
>>> soup = TexSoup(r''' | ||
... \begin{itemize} | ||
... \item Hello | ||
... \item Bye | ||
... \end{itemize}''') | ||
>>> tmp = soup.item | ||
>>> soup.itemize.remove(soup.item) | ||
>>> soup.itemize | ||
\begin{itemize} | ||
\item Bye | ||
\end{itemize} | ||
>>> soup.insert(1, tmp) | ||
>>> soup | ||
\begin{itemize} | ||
\item Hello | ||
\item Bye | ||
\end{itemize} | ||
|
||
See :class:`TexSoup.data.TexNode` for more utilities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ def run_tests(self): | |
sys.exit(errno) | ||
|
||
|
||
VERSION = '0.3.0' | ||
VERSION = '0.3.1' | ||
|
||
setup( | ||
name="TexSoup", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters