# HG changeset patch # User Nolan Prescott # Date 1613434079 18000 # Mon Feb 15 19:07:59 2021 -0500 # Node ID 15dee490aae9a2975d58c47d7f957e7f1860a920 # Parent 43ac8a2778079d86ca6255cea7e07867c747ff76 fix to include links in leaders but not org-mode table of contents. okay so it is a hack, but it works. additionally, I've accidentally squashed in a fix to include add xml:base per post in the feed. oh well. diff --git a/quiescent/feed.py b/quiescent/feed.py --- a/quiescent/feed.py +++ b/quiescent/feed.py @@ -26,7 +26,6 @@ def _feed(all_posts, date=None, name=None, domain=None, feed_link=None, feed_author=None): _feed = ET.Element('{http://www.w3.org/2005/Atom}feed') - _feed.attrib['xml:base'] = domain title = ET.SubElement(_feed, 'title') title.text = name link = ET.SubElement(_feed, 'link') @@ -56,6 +55,7 @@ updated = ET.SubElement(entry, 'updated') updated.text = post.date_time.isoformat() content = ET.SubElement(entry, 'content') + content.attrib['xml:base'] = urljoin(domain, post.file_path) content.attrib['type'] = 'html' content.text = post.html_body return entry diff --git a/quiescent/post.py b/quiescent/post.py --- a/quiescent/post.py +++ b/quiescent/post.py @@ -39,10 +39,18 @@ self.tag_stack.append(tag) elif tag == 'span': self.tag_stack.append(tag) - elif self.tag_stack and (tag == self.tag_stack[-1]): - self.DONE = True elif tag == 'p': self.tag_stack.append(tag) + elif tag == 'div': + self.tag_stack.append(tag) + elif (tag == 'a' and not self.DONE + and # hack to avoid org-mode table of contents + 'div' not in self.tag_stack): + self.tag_stack.append(tag) + self.leader.append('') def handle_endtag(self, tag): if self.tag_stack and (tag == self.tag_stack[-1]): @@ -56,8 +64,10 @@ self.title = data elif self.tag_stack[-1] == 'span' and not self.date: self.date = data - elif not self.DONE: + elif not self.DONE and 'div' not in self.tag_stack: # steadfastly ignore table of contents links self.leader.append(data) + if self.tag_stack[-1] == 'a': + self.leader.append('') def post_data(self): leader = "".join(self.leader).strip()