06-04-2011, 07:49 PM | #1 |
Connoisseur
Posts: 58
Karma: 12
Join Date: May 2011
Location: Deland, Florida
Device: Kindle 3
|
Remove "alink", not just change it to text
I found code on this forum written by Starson17 which allows for the changing of an "alink" to a text object. The code works fine and once converted to a text object, I can manipulate it with extra css to diminish the text's size and therefore accomplish part of what I want: to maximize the available screen area for viewing an image.
Starson17's code is: Code:
def preprocess_html(self, soup): for alink in soup.findAll('a'): if alink.string is not None: tstr = alink.string alink.replaceWith(tstr) return soup Seems to me if I could define the "tstr" as a null item, there would no longer be an "alink". I tried "tstr = []" but that did not work! Any other suggestions? Any help would be greatly appreciated. |
06-04-2011, 07:54 PM | #2 |
creator of calibre
Posts: 43,850
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
tag.extract()
|
Advert | |
|
06-04-2011, 10:35 PM | #3 |
Connoisseur
Posts: 58
Karma: 12
Join Date: May 2011
Location: Deland, Florida
Device: Kindle 3
|
IT WORKED!!! Thank you!!!
Kovid,
I was a little frustrated that you were being so cryptic, especially since I am so very new to all of this. But I want to thank you for giving me a hint and letting me learn. I did research on your suggestion to use "tag.extract()". I fumbled around but finally got it! I can not tell you how thrilling it was, even though you could have written the code while half asleep. Code:
def preprocess_html(self, soup): for tag in soup.findAll('a'): tag.extract() return soup I am 90% finished with my objective but still need to deal with the font size of the TOC. I will post a question about that soon. Thank you. |
06-04-2011, 10:52 PM | #4 |
creator of calibre
Posts: 43,850
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You're welcome, I firmly believe in teaching a man to fish, as opposed to giving him fish Nothing quite like the feeling of figuring something out for yourself.
|
06-06-2011, 11:37 AM | #5 |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
I'll throw my thanks in here as well. Your philosophy of "teach a man to fish" is more than just a philosophy - you actively put it into your work by creating the code development environment, the API, tutorials on use thereof, the recipe system, the plugin system, etc. For all of that - Thanks.
|
Advert | |
|
Tags |
code |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Remove from Archive (book already "deleted" in Amazon account) | kindletommy | Amazon Kindle | 9 | 08-09-2012 06:17 PM |
Orphaned files after "Remove from iTunes device" | TheRealRalph | Devices | 4 | 04-18-2011 09:13 AM |
How do I remove the "Archived" Book shelf from my nook color? | leesiulung | Nook Color & Nook Tablet | 0 | 02-24-2011 03:02 PM |
How to remove "Fully read" books from "Last Open" list? | pjeanetta | PocketBook | 4 | 12-08-2010 10:30 AM |