03-28-2017, 09:48 PM | #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.
|
03-28-2017, 09:50 PM | #2 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use postprocess_html and simply remove the href attribute from all <a> tags.
|
03-28-2017, 10:36 PM | #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-28-2017 at 11:50 PM. |
|
03-29-2017, 03:49 AM | #4 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
postprocess_html takes two arguments, otherwise it looks fine.
|
03-29-2017, 09:27 AM | #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 |
|
03-29-2017, 10:51 AM | #6 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You probably got the indentation level wrong.
|
03-29-2017, 12:37 PM | #7 |
Enthusiast
Posts: 39
Karma: 10
Join Date: Nov 2011
Device: Kindle Paperwhite
|
|
03-29-2017, 07:45 PM | #8 |
creator of calibre
Posts: 43,858
Karma: 22666666
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
|
03-29-2017, 08:16 PM | #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 05:27 PM |
How does ebook-convert react to plain text input | porphyry5 | Conversion | 7 | 11-06-2015 07:27 PM |
New Software: convert plain text files to epub/mobi format | MobiEpubMaker | Workshop | 38 | 04-27-2015 05:52 AM |
convert plain text to other formats ? | Joebill | Other formats | 6 | 05-10-2010 11:10 PM |
A java/Groovy program to convert plain text into pdf for eslick | dracodoc | 1 | 04-12-2009 09:29 AM |