spec.texout.write(b'\\usepackage[' +
spec.geometry.encode('UTF-8') +
b']{geometry}\n')
- spec.texout.write(b'\\begin{document}\n')
+ spec.texout.write(b'''\\begin{document}
+\\newcommand{\\href}[2]{#2\\footnote{#1}}
+''')
url = flatURL(spec.url)
html = parse(spec.htmlfilter(spec.fetcher.fetch(url)))
num_chunks = ilen(chunkDOMs(html))
assert re.match(br'''\\documentclass{article}
(\\usepackage{[a-z]+}\n)+\\usepackage\[margin=20mm\]{geometry}
\\begin{document}
-This is glowfic
+\\newcommand{\\href}\[2\]{#2\\footnote{#1}}
+This is \\href{https://glowfic.com}{glowfic}
You \\emph{sure}\?
<body>
<div class="post-container post-post">
<div class="post-edit-box">We don't want edit boxes</div>
- <div class="post-content">This is glowfic</div>
+ <div class="post-content">This is <a href="https://glowfic.com">glowfic</a></div>
<div class="post-footer">We don't want footers</div>
</div>
<div class="flat-post-replies">
def texify(self, html: Tag) -> bytes:
if html.name == 'em':
return b'\\emph{' + self._texify_children(html).strip() + b'}\n'
+ if html.name == 'a' and 'href' in html.attrs:
+ return b'\\href{' + html.attrs['href'].encode(
+ 'UTF-8') + b'}{' + self._texify_children(html).strip() + b'}\n'
return self._texify_children(html)