Skip to content

Commit

Permalink
2.6.2: Fix. Add also removal of H1 to clean up all titles, to insert …
Browse files Browse the repository at this point in the history
…a new one
  • Loading branch information
mmagnus committed Jun 4, 2020
1 parent b885fed commit 33c5985
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Pocket.recipe
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env python
# vim:ft=python tabstop=8 expandtab shiftwidth=4 softtabstop=4
from __future__ import print_function
__version__ = '2.6.1'
__version__ = '2.6.2'

"""
2.6.2: Fix. Add also removal of H1 to clean up all titles, to insert a new one
**TAGS** (list of strings or empty list: []) if [] (empty list) then the plugin will connect Pocket and fetch articles based on the configuration of the plugin.
Next, the plugin will get tags of these articles and group them into sections in the final ebook.
If TAGS has elements, e.g., TAGS = ['tag1', 'tag2'] then only these tags will be fetched from Pocket.
Expand Down Expand Up @@ -446,10 +449,17 @@ class Pocket(BasicNewsRecipe):

def postprocess_html(self, soup, first):
title = soup.find('title').text # get title

h1s = soup.findAll('h1') # get all h1 headers
for h1 in h1s:
if title in h1.text:
h1 = h1.clear() # clean this tag, so the h1 will be there only

h2s = soup.findAll('h2') # get all h2 headers
for h2 in h2s:
if title in h2.text:
h2 = h2.clear() # clean this tag, so the h1 will be there only

body = soup.find('body')
new_tag = soup.new_tag('h1')
new_tag.append(title)
Expand Down

0 comments on commit 33c5985

Please sign in to comment.