]> git.armaanb.net Git - lightcards.git/blobdiff - lightcards/parse.py
Add table number option
[lightcards.git] / lightcards / parse.py
index 95319f4628c5aecc1f683267be547f3f0fbbaf72..5d9b4024fd15f7d8491a6271fd163464279f5bc2 100644 (file)
@@ -24,7 +24,7 @@ def md2html(file):
     return outp
 
 
-def parse_html(html, lenient):
+def parse_html(html, args):
     """Use BeautifulSoup to parse the HTML"""
 
     def clean_text(inp):
@@ -33,12 +33,12 @@ def parse_html(html, lenient):
     soup = BeautifulSoup(html, "html.parser")
     outp, ths = [], []
 
-    for table in soup.find_all("table"):
+    for i, table in enumerate(soup.find_all("table")):
         ths = table.find_all("th")
         if len(ths) != 2:
-            if not lenient:
+            if not args.lenient:
                 raise Exception("lightcards: Headings malformed")
-        else:
+        elif args.table == i:
             try:
                 for x in table.find_all("tr"):
                     y = x.find_all("td")