]> git.armaanb.net Git - lightcards.git/blobdiff - lightcards/parse.py
Add comments to code
[lightcards.git] / lightcards / parse.py
index 6f3c25f6baf0d40b75fbdcfcf6ecbe4e850fae98..65cad627d4cd25e38dce77973fb9b25ae958a6dd 100755 (executable)
@@ -10,11 +10,13 @@ from .deck import Card
 
 
 def md2html(file):
+    """Use the markdown module to convert input to HTML"""
     with open(file, "r", encoding="utf-8") as input_file:
         return markdown.markdown(input_file.read(), extensions=['tables'])
 
 
 def parse_html(html):
+    """Use BeautifulSoup to parse the HTML"""
     def clean_text(inp):
         return inp.get_text().rstrip()
 
@@ -30,6 +32,7 @@ def parse_html(html):
     for x in soup.find_all("tr"):
         outp.append(Card([clean_text(y) for y in x.find_all("td")]))
 
+    # Return a tuple of nested lists
     return ([clean_text(x) for x in soup.find_all("th")],
             clean_list(outp))