return outp
-def parse_html(html, lenient):
+def parse_html(html, args):
"""Use BeautifulSoup to parse the HTML"""
def clean_text(inp):
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")
action="store_true",
help="don't raise exception if tables are malformed",
)
+ parser.add_argument(
+ "-t",
+ "--table",
+ metavar="num_table",
+ type=int,
+ help="specify which table to use if multiple are given",
+ )
parser.add_argument(
"-a",
"--alphabetize",
sys.tracebacklimit = 0
global headers, stack
- (headers, stack) = parse.parse_html(parse.md2html(args.inp), args.lenient)
+ (headers, stack) = parse.parse_html(parse.md2html(args.inp), args)
show(args, stack, headers, conf)
.TP
\f[B]-l\f[R], \f[B]--lenient\f[R]
Don\[cq]t raise exception if tables are malformed
+.TP
+\f[B]-t\f[R] [int], \f[B]--table\f[R] [int]
+If multiple tables are provided in the input files, specify which
.SH KEYS
.TP
\f[B]l\f[R], \f[B]right\f[R]
**-l**, **\--lenient**
: Don't raise exception if tables are malformed
+**-t** \[int\], **\--table** \[int\]
+: If multiple tables are provided in the input files, specify which
+
# KEYS
**l**, **right**
: Next card