]> git.scottworley.com Git - paperdoorknob/blobdiff - paperdoorknob.py
Specify page geometry
[paperdoorknob] / paperdoorknob.py
index 653d0c65d8d781790aceaff6d59f91a742a277ca..26eb7be054a823b6183bea6dff3415dfef713a6a 100644 (file)
@@ -20,14 +20,6 @@ def parse(content: bytes) -> BeautifulSoup:
     return BeautifulSoup(content, 'html.parser')
 
 
     return BeautifulSoup(content, 'html.parser')
 
 
-def clean(html: BeautifulSoup) -> BeautifulSoup:
-    for eb in html.find_all("div", class_="post-edit-box"):
-        eb.decompose()
-    for footer in html.find_all("div", class_="post-footer"):
-        footer.decompose()
-    return html
-
-
 def replies(html: BeautifulSoup) -> Iterable[Tag]:
     def text() -> Tag:
         body = html.body
 def replies(html: BeautifulSoup) -> Iterable[Tag]:
     def text() -> Tag:
         body = html.body
@@ -45,9 +37,15 @@ def replies(html: BeautifulSoup) -> Iterable[Tag]:
 
 
 def process(spec: Spec) -> None:
 
 
 def process(spec: Spec) -> None:
-    spec.texout.write(b'\\documentclass{article}\n\\begin{document}\n')
-    html = clean(parse(spec.fetcher.fetch(spec.url)))
+    spec.texout.write(b'\\documentclass{article}\n')
+    if spec.geometry is not None:
+        spec.texout.write(b'\\usepackage[' +
+                          spec.geometry.encode('UTF-8') +
+                          b']{geometry}\n')
+    spec.texout.write(b'\\begin{document}\n')
+    html = parse(spec.htmlfilter(spec.fetcher.fetch(spec.url)))
     for r in replies(html):
     for r in replies(html):
+        spec.domfilter(r)
         spec.texout.write(spec.texifier.texify(r))
     spec.texout.write(b'\\end{document}\n')
 
         spec.texout.write(spec.texifier.texify(r))
     spec.texout.write(b'\\end{document}\n')