|
|
#1 |
|
Enthusiast
![]() Posts: 39
Karma: 10
Join Date: Nov 2011
Device: Kindle Paperwhite
|
Convert hyperlinks to plain text
What's the best way to convert hyperlinks to plain text in my recipes? I often accidentally touch a hyperlink in my Kindle when turning pages and it tries to then bring up a browser to the link. I'd rather just remove all the hyperlinks if possible.
|
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,615
Karma: 28549044
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use postprocess_html and simply remove the href attribute from all <a> tags.
|
|
|
|
| Advert | |
|
|
|
|
#3 | |
|
Enthusiast
![]() Posts: 39
Karma: 10
Join Date: Nov 2011
Device: Kindle Paperwhite
|
Quote:
def postprocess_html(self, soup): for a in soup.findAll('a', href=True): del a['href'] return soup Last edited by anleva; 03-29-2017 at 12:50 AM. |
|
|
|
|
|
|
#4 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,615
Karma: 28549044
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
postprocess_html takes two arguments, otherwise it looks fine.
|
|
|
|
|
|
#5 | |
|
Enthusiast
![]() Posts: 39
Karma: 10
Join Date: Nov 2011
Device: Kindle Paperwhite
|
Quote:
def postprocess_html(self, soup, first_fetch): for a in soup.findAll('a', href=True): del a['href'] return soup |
|
|
|
|
| Advert | |
|
|
|
|
#6 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,615
Karma: 28549044
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You probably got the indentation level wrong.
|
|
|
|
|
|
#7 |
|
Enthusiast
![]() Posts: 39
Karma: 10
Join Date: Nov 2011
Device: Kindle Paperwhite
|
|
|
|
|
|
|
#8 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,615
Karma: 28549044
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No, the indentation of the entire postprocess_html method needs to be increased by one level so that it belongs to the class
|
|
|
|
|
|
#9 |
|
Enthusiast
![]() Posts: 39
Karma: 10
Join Date: Nov 2011
Device: Kindle Paperwhite
|
kovidgoyal, you are the man! That worked. Thanks for your patience, I am learning much along the way.
anleva |
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to paste as plain-text in Sigil? | elenderg | Sigil | 4 | 09-28-2016 06:27 PM |
| How does ebook-convert react to plain text input | porphyry5 | Conversion | 7 | 11-06-2015 08:27 PM |
| New Software: convert plain text files to epub/mobi format | MobiEpubMaker | Workshop | 38 | 04-27-2015 06:52 AM |
| convert plain text to other formats ? | Joebill | Other formats | 6 | 05-11-2010 12:10 AM |
| A java/Groovy program to convert plain text into pdf for eslick | dracodoc | 1 | 04-12-2009 10:29 AM | |