This commit is contained in:
Kovid Goyal 2011-02-03 20:42:19 -07:00
parent 7d79ccd901
commit 7610a7b773

View File

@ -16,7 +16,6 @@ from calibre.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace
from calibre.ebooks.oeb.stylizer import Stylizer from calibre.ebooks.oeb.stylizer import Stylizer
from calibre.ebooks.pdb.ereader import image_name from calibre.ebooks.pdb.ereader import image_name
from calibre.ebooks.pml import unipmlcode from calibre.ebooks.pml import unipmlcode
from calibre.utils.cleantext import clean_ascii_chars
TAG_MAP = { TAG_MAP = {
'b' : 'B', 'b' : 'B',
@ -192,7 +191,7 @@ class PMLMLizer(object):
# Remove excessive spaces # Remove excessive spaces
text = re.sub('[ ]{2,}', ' ', text) text = re.sub('[ ]{2,}', ' ', text)
# Condense excessive \c empty line sequences. # Condense excessive \c empty line sequences.
text = re.sub('(\\c\s*\\c\s*){2,}', '\\c \n\\c\n', text) text = re.sub('(\\c\s*\\c\s*){2,}', '\\c \n\\c\n', text)
@ -248,7 +247,7 @@ class PMLMLizer(object):
text.append(w) text.append(w)
elif tag == 'br': elif tag == 'br':
text.append('\n\\c \n\\c\n') text.append('\n\\c \n\\c\n')
# TOC markers. # TOC markers.
toc_name = elem.attrib.get('name', None) toc_name = elem.attrib.get('name', None)
toc_id = elem.attrib.get('id', None) toc_id = elem.attrib.get('id', None)
@ -299,7 +298,7 @@ class PMLMLizer(object):
if style_tag and style_tag not in tag_stack+tags: if style_tag and style_tag not in tag_stack+tags:
text.append('\\%s' % style_tag) text.append('\\%s' % style_tag)
tags.append(style_tag) tags.append(style_tag)
# margin left # margin left
try: try:
mms = int(float(style['margin-left']) * 100 / style.height) mms = int(float(style['margin-left']) * 100 / style.height)
@ -307,7 +306,7 @@ class PMLMLizer(object):
text.append('\\T="%s%%"' % mms) text.append('\\T="%s%%"' % mms)
except: except:
pass pass
# Soft scene breaks. # Soft scene breaks.
try: try:
ems = int(round((float(style.marginTop) / style.fontSize) - 1)) ems = int(round((float(style.marginTop) / style.fontSize) - 1))
@ -350,7 +349,7 @@ class PMLMLizer(object):
text.append('\n\n') text.append('\n\n')
else: else:
# closing \c and \r need to be placed # closing \c and \r need to be placed
# on the next line per PML spec. # on the next line per PML spec.
if tag in ('c', 'r'): if tag in ('c', 'r'):
text.append('\n\\%s' % tag) text.append('\n\\%s' % tag)
else: else: