mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Revert PML indent changes. PML Output: Cleaner handling of paragraph indentation.
This commit is contained in:
parent
e3823faad4
commit
67ae787d45
@ -71,8 +71,8 @@ class PML_HTMLizer(object):
|
||||
'ra': ('<span id="r%s"></span><a href="#%s">', '</a>'),
|
||||
'c': ('<div style="text-align: center; margin: auto;">', '</div>'),
|
||||
'r': ('<div style="text-align: right;">', '</div>'),
|
||||
't': ('<div style="text-indent: 1.5em;">', '</div>'),
|
||||
'T': ('<div style="text-indent: %s;">', '</div>'),
|
||||
't': ('<div style="margin-left: 5%;">', '</div>'),
|
||||
'T': ('<div style="margin-left: %s;">', '</div>'),
|
||||
'i': ('<span style="font-style: italic;">', '</span>'),
|
||||
'u': ('<span style="text-decoration: underline;">', '</span>'),
|
||||
'd': ('<span style="text-decoration: line-through;">', '</span>'),
|
||||
|
@ -182,9 +182,14 @@ class PMLMLizer(object):
|
||||
# Remove excessive spaces
|
||||
text = re.sub('[ ]{2,}', ' ', text)
|
||||
|
||||
# Remove excessive newlines
|
||||
# Remove excessive newlines.
|
||||
text = re.sub('\n[ ]+\n', '\n\n', text)
|
||||
text = re.sub('\n\n\n+', '\n\n', text)
|
||||
if self.opts.remove_paragraph_spacing:
|
||||
text = re.sub('\n{2,}', '\n', text)
|
||||
text = re.sub('(?imu)^(?P<text>.+)$', lambda mo: mo.group('text') if re.search(r'\\[XxCm]', mo.group('text')) else ' %s' % mo.group('text'), text)
|
||||
else:
|
||||
text = re.sub('\n{4,}', '\n\n\n', text)
|
||||
|
||||
|
||||
return text
|
||||
|
||||
@ -204,12 +209,10 @@ class PMLMLizer(object):
|
||||
tag_count = 0
|
||||
|
||||
# Are we in a paragraph block?
|
||||
if tag in BLOCK_TAGS:# or style['display'] in BLOCK_STYLES:
|
||||
if tag in BLOCK_TAGS: # or style['display'] in BLOCK_STYLES:
|
||||
if 'block' not in tag_stack:
|
||||
tag_count += 1
|
||||
tag_stack.append('block')
|
||||
if self.opts.remove_paragraph_spacing:
|
||||
text.append('\\t')
|
||||
|
||||
# Process tags that need special processing and that do not have inner
|
||||
# text. Usually these require an argument
|
||||
@ -289,14 +292,10 @@ class PMLMLizer(object):
|
||||
close_tag_list.insert(0, tag_stack.pop())
|
||||
text += self.close_tags(close_tag_list)
|
||||
if tag in SEPARATE_TAGS:
|
||||
text.append('\n')
|
||||
if not self.opts.remove_paragraph_spacing:
|
||||
text.append('\n')
|
||||
text.append('\n\n')
|
||||
|
||||
if 'block' not in tag_stack and text and text[-1] != '\n':
|
||||
text.append('\n')
|
||||
if not self.opts.remove_paragraph_spacing:
|
||||
text.append('\n')
|
||||
if 'block' not in tag_stack:
|
||||
text.append('\n\n')
|
||||
|
||||
#if style['page-break-after'] == 'always':
|
||||
# text.append('\\p')
|
||||
|
Loading…
x
Reference in New Issue
Block a user