01-05-2019, 08:03 AM | #1 |
Connoisseur
Posts: 82
Karma: 10
Join Date: Dec 2015
Device: Kindle
|
Convert links to text in downloaded news
Downloaded news feeds can contain many hyperlinks to web pages which exist in the RSS articles. Using my kindle I can't stop inadvertently pressing text with embedded links and jumping to web pages when I only want to page forward in the document.
Is there a recipe command that would convert all the web hyperlinks to 'flat' text, i.e. the text with underscoring still appears with the article but there is no underlying link to a web page. I did try this code found in a sticky recipe post but it does not kill the links. Spoiler:
Thanks in advance. |
01-05-2019, 10:32 AM | #2 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
That code wil lwork fine as long as you insert it with the correct indentation in the recipe and then run the customized recipe not th ebuiltin one.
|
Advert | |
|
01-05-2019, 12:49 PM | #3 |
Connoisseur
Posts: 82
Karma: 10
Join Date: Dec 2015
Device: Kindle
|
Kovid,
I checked indentation on the code and believe it is correct but am not an expert. The hyperlinks are all still active. I am testing with a copy of the latest Fox News recipe that you loaded as built-in some time ago. Is there some other code to be added to reflect 'customized recipe'? Copy of test recipe attached. Thanks in advance. |
01-05-2019, 10:31 PM | #4 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
preprocess_html has to a be memeber of the recipe class, which means it has to be inside the class definition indented by four spaces.
|
01-06-2019, 10:20 AM | #5 |
Connoisseur
Posts: 82
Karma: 10
Join Date: Dec 2015
Device: Kindle
|
I moved the code inside the "class testnewssource(BasicNewsRecipe):" statement, so at the very bottom of the recipe, with same indent of 4 as the feeds, but the links are all still active.
|
Advert | |
|
01-06-2019, 11:02 AM | #6 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
here you go
|
01-06-2019, 12:02 PM | #7 |
Connoisseur
Posts: 82
Karma: 10
Join Date: Dec 2015
Device: Kindle
|
Great - that works.
Is there any easy way to retain the blue text formatting for the linked-text, as a visible indicator that the original article has a link embedded below that text? Thanks. |
01-06-2019, 08:07 PM | #8 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
a['style'] = 'color: blue'
|
01-06-2019, 10:27 PM | #9 |
Connoisseur
Posts: 82
Karma: 10
Join Date: Dec 2015
Device: Kindle
|
Great - thanks again.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Convert external links to internal links | sup | Recipes | 2 | 11-28-2013 09:39 AM |
news paper not getting downloaded | gp_mbe | Recipes | 2 | 11-15-2012 06:32 AM |
Kindle 3: Downloaded news has [?] in some of the articals? | CalgaryToad | Devices | 5 | 02-01-2011 10:18 AM |
different "delete downloaded news" values per news source? | scottfree | Calibre | 1 | 01-19-2011 11:15 AM |
Add only news tag to downloaded news? | eric11210 | Calibre | 2 | 08-06-2010 05:51 AM |