View Single Post
Old 03-07-2009, 01:30 PM   #325
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,131
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
Question, how do I force page breaks in news recipes? I tried adding: extra_css = .chapter { page-break-before: always } but I think Calibre is overriding it by adding: style="page-break-before:avoid;page-break-after:avoid" to every <div class="chapter"> entry.

I also tried adding: <span style="page-break-before: always"></span> before <div class="chapter"> to the print version but it looks like those lines are just being stripped away. Pretty sure this is a news specific behavior since using the command line html2epub on the individual print version gives me a really nice epub with page breaks.

Code:

#!/usr/bin/env  python

__license__   = 'GPL v3'
__copyright__ = '2009, tifa1984'
'''
www.fanfiction.net
'''

import string, re
from calibre.web.feeds.news import BasicNewsRecipe

class FFNetFeed(BasicNewsRecipe):
	title	= u'FFNetFeed'
	__author__	= 'FanFiction.Net'
	description	= 'unleash your imagination'
	
	oldest_article = 7
	
	extra_css = .chapter { page-break-before: always }
	
	feeds	= [
		('Rurouni Kenshin - Kaoru/Kenshin', 'http://www.fanfiction.net/atom/l/355/10/0/1/1/0/410/411/0/0/')
		]
	
	def print_version(self, url):
		main, sep, rest = url.rpartition('/1/')
		rmain, rsep, storyid = main.rpartition('/s/')
		return 'http://localhost/flag/print.php?source=ffnet&format=news&storyid=' + storyid
I'm attaching the PHP scripts I used for generating the print version along with some sample HTML output. I'm trying to convert the algorithm to a Calibre recipe but alas, it's taking me a long time to do so.

Dependencies:
php5-cli
php5-curl
php5-tidy
Attached Files
File Type: zip flag.zip (12.8 KB, 315 views)
File Type: zip sample.zip (141.7 KB, 318 views)
ilovejedd is offline