X-Git-Url: https://git.armaanb.net/?p=lightcards.git;a=blobdiff_plain;f=lightcards%2Fparse.py;fp=lightcards%2Fparse.py;h=5d9b4024fd15f7d8491a6271fd163464279f5bc2;hp=95319f4628c5aecc1f683267be547f3f0fbbaf72;hb=8bbca6fa61b644ca183166666934ecaf7f55f4d0;hpb=9c901da1569d3c2ec5f4a59f57e5ad067112b4ba diff --git a/lightcards/parse.py b/lightcards/parse.py index 95319f4..5d9b402 100644 --- a/lightcards/parse.py +++ b/lightcards/parse.py @@ -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")