Initial support for preprocessing BD files

This commit is contained in:
Kovid Goyal 2007-10-06 02:29:49 +00:00
parent c36e73b616
commit 59faf929ea
2 changed files with 14 additions and 0 deletions

View File

@ -93,6 +93,19 @@ class HTMLConverter(object):
]
# Fix Book Designer markup
BOOK_DESIGNER = [
# Create header tags
(re.compile('<h2.*?id=BookTitle.*?>(.*?)</span>', re.IGNORECASE|re.DOTALL),
lambda match : '<h1 align="center">%s</h1>'%(match.group(1),)),
(re.compile('<h2.*?id=BookAuthor.*?>(.*?)</span>', re.IGNORECASE|re.DOTALL),
lambda match : '<h2 align="right">%s</h2>'%(match.group(1),)),
(re.compile('<span.*?id=title.*?>(.*?)</span>', re.IGNORECASE|re.DOTALL),
lambda match : '<h2>%s</h2>'%(match.group(1),)),
(re.compile('<span.*?id=subtitle.*?>(.*?)</span>', re.IGNORECASE|re.DOTALL),
lambda match : '<h3>%s</h3>'%(match.group(1),)),
]
def __hasattr__(self, attr):
if hasattr(self.options, attr):
return True

View File

@ -207,6 +207,7 @@ class LRFSingleDialog(QDialog, Ui_LRFSingleDialog):
ph = 'Preprocess the file before converting to LRF. This is useful if you know that the file is from a specific source. Known sources:'
ph += '<ol><li><b>baen</b> - Books from BAEN Publishers</li>'
ph += '<li><b>pdftohtml</b> - HTML files that are the output of the program pdftohtml</li>'
ph += '<li><b>book-designer</b> - HTML0 files from Book Designer</li>'
self.preprocess.setToolTip(ph)
self.preprocess.setWhatsThis(ph)
for profile in self.PARSER.get_option('--profile').choices: