![]() |
#1 | ||
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Apr 2011
Device: Amazon Kindle 3
|
Remove <br /> together with span, and only span
I am working on a recipe for the danish IT news site version2.dk - code is below in the spoiler. It's almost done. I have removed all items that shouldn't be there, but I have some nitpicking left.
In the articles there was some links to related articles. I removed those, but it leaves a rather large space between two segments. To illustrate: Quote:
Quote:
Spoiler:
|
||
![]() |
![]() |
![]() |
#2 |
Connoisseur
![]() Posts: 63
Karma: 10
Join Date: Oct 2010
Device: KDXG, Kobo Glo, Kobo Aura HD
|
Add the preprocess_regexps option:
Code:
preprocess_regexps = [ (re.compile(r'</?a[^>]*>'),lambda match: ''), (re.compile(r'<span[^>]*article-link-id.*?<br\s*\/?><br\s*\/?>'), lambda match: '')] keep_only_tags = [dict(name='div', attrs={'class':'article'})] remove_tags = [ dict(name='p',attrs={'class':'meta links'}), dict(name='div',attrs={'class':'float-right'}), #dict(name='span',attrs={'class':'article-link-id'}) ] feeds = [ If you want a suggestion, you can add an extra_css option to tweak the final appearence of the article when displayed. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Apr 2011
Device: Amazon Kindle 3
|
Thank you very much!
I just add'ed the following extra_css (which I borrowed from The New Yorker receipe), but I really can't see any difference on my kindle. Code:
extra_css = """ body {font-family: "Times New Roman",Times,serif} .articleauthor{color: #9F9F9F; font-family: Arial, sans-serif; font-size: small; text-transform: uppercase} .rubric,.dd,h6#credit{color: #CD0021; font-family: Arial, sans-serif; font-size: small; text-transform: uppercase} .descender:first-letter{display: inline; font-size: xx-large; font-weight: bold} .dd,h6#credit{color: gray} .c{display: block} .caption,h2#articleintro{font-style: italic} .caption{font-size: small} """ Last edited by Razzia; 05-29-2011 at 07:01 PM. |
![]() |
![]() |
![]() |
#4 | |
Connoisseur
![]() Posts: 63
Karma: 10
Join Date: Oct 2010
Device: KDXG, Kobo Glo, Kobo Aura HD
|
Quote:
Try to run your recipe with ebook-convert as explained here, then open one of the pages in /debug/input with a text editor (like Notepad++) to see how the html is after your recipe has cleaned it. You have to provide css styles to the classes or elements as they are named there. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Trouble removing span class | mufc | Recipes | 3 | 03-18-2011 03:29 PM |
Why define a paragraph as a span with no different or extra formatting? | bfollowell | ePub | 7 | 03-16-2011 10:30 PM |
'Heading color' and 'p class span' | mufc | Recipes | 7 | 12-22-2010 09:02 PM |
Span tags, h1s and emspaces | ConorHughes | ePub | 11 | 09-30-2010 05:00 PM |
STREET & CLAIRVOYANCE by Ryan A. Span | Winter | Self-Promotions by Authors and Publishers | 36 | 09-01-2010 11:09 AM |