Repository: alvinwan/TexSoup

Issue:
Commands in environment arguments cannot be deleted
For example:

```python
>>> import TexSoup
>>> ts = TexSoup.TexSoup(r'\begin{env}{\test}\end{env}')
>>> ts.find('test').delete()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/atlas/physics-office/src/TexSoup/TexSoup/data.py", line 473, in delete
    parent.remove(self)
  File "/home/user/atlas/physics-office/src/TexSoup/TexSoup/data.py", line 551, in remove
    self.expr.remove(node.expr)
  File "/home/user/atlas/physics-office/src/TexSoup/TexSoup/data.py", line 844, in remove
    index = self._contents.index(expr)
ValueError: TexCmd('test') is not in list
```

Discussion:

Patch:
diff --git a/README.md b/README.md
index df2a1d4..754a26b 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
 [![Build Status](https://travis-ci.org/alvinwan/TexSoup.svg?branch=master)](https://travis-ci.org/alvinwan/TexSoup)
 [![Coverage Status](https://coveralls.io/repos/github/alvinwan/TexSoup/badge.svg?branch=master)](https://coveralls.io/github/alvinwan/TexSoup?branch=master)
 
-TexSoup is a fault-tolerant, Python3 package for searching, navigating, and modifying LaTeX documents.
+TexSoup is a fault-tolerant, Python3 package for searching, navigating, and modifying LaTeX documents. You can skip installation and try TexSoup directly, using the [pytwiddle demo &rarr;](https://pytwiddle.com/?id=example:latex.py)
 
 - [Getting Started](https://github.com/alvinwan/TexSoup#Getting-Started)
 - [Installation](https://github.com/alvinwan/TexSoup#Installation)
@@ -71,7 +71,7 @@ life & common
 [\item red lemon, \item life]
 ```
 
-For more use cases, see [the Quickstart Guide](https://texsoup.alvinwan.com/docs/quickstart.html). Or, try TexSoup [online, via repl.it &rarr;](https://repl.it/@ALVINWAN1/texsoup)
+For more use cases, see [the Quickstart Guide](https://texsoup.alvinwan.com/docs/quickstart.html). Or, try TexSoup [online, via pytwiddle &rarr;](https://pytwiddle.com/?id=example:latex.py)
 
 Links:
 
diff --git a/TexSoup/data.py b/TexSoup/data.py
index 8e04c24..76591e5 100644
--- a/TexSoup/data.py
+++ b/TexSoup/data.py
@@ -467,16 +467,11 @@ class TexNode(object):
         \textit{keep me!}
         """
 
-        # TODO: needs better abstraction for supports contents
-        parent = self.parent
-        if parent.expr._supports_contents():
-            parent.remove(self)
-            return
-
-        # TODO: needs abstraction for removing from arg
-        for arg in parent.args:
-            if self.expr in arg.contents:
-                arg._contents.remove(self.expr)
+        for arg in self.parent.args:
+            if self in arg.contents:
+                arg.remove(self)
+                return
+        self.parent.remove(self)
 
     def find(self, name=None, **attrs):
         r"""First descendant node matching criteria.


Test patch:
diff --git a/tests/test_api.py b/tests/test_api.py
index 7eb44fb..af8873d 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -100,6 +100,12 @@ def test_delete_arg():
     soup.bar.delete()
 
 
+def test_delete_env_arg():
+    """Delete an element from an environment arg in the parse tree"""
+    soup = TexSoup(r'\begin{foo}{\bar{\baz}}\end{foo}')
+    soup.bar.delete()
+
+
 def test_delete_token():
     """Delete Token"""
     soup = TexSoup(r"""