mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
FB2 Output: Remove section regexp what do nothing and rearrange regexps
This commit is contained in:
parent
d7a4e10c60
commit
e7175e802b
@ -85,6 +85,9 @@ class FB2MLizer(object):
|
|||||||
# Put the paragraph following a paragraph on a separate line.
|
# Put the paragraph following a paragraph on a separate line.
|
||||||
text = re.sub(r'(?mu)</p>\s*<p>', '</p>\n<p>', text)
|
text = re.sub(r'(?mu)</p>\s*<p>', '</p>\n<p>', text)
|
||||||
|
|
||||||
|
if self.opts.insert_blank_line:
|
||||||
|
text = re.sub(r'(?mu)</p>', '</p><empty-line/>', text)
|
||||||
|
|
||||||
# Clean up title endings.
|
# Clean up title endings.
|
||||||
text = re.sub(r'(?mu)\s+</title>', '</title>', text)
|
text = re.sub(r'(?mu)\s+</title>', '</title>', text)
|
||||||
# Remove empty title elements.
|
# Remove empty title elements.
|
||||||
@ -92,6 +95,10 @@ class FB2MLizer(object):
|
|||||||
# Put the paragraph following a title on a separate line.
|
# Put the paragraph following a title on a separate line.
|
||||||
text = re.sub(r'(?mu)</title>\s*<p>', '</title>\n<p>', text)
|
text = re.sub(r'(?mu)</title>\s*<p>', '</title>\n<p>', text)
|
||||||
|
|
||||||
|
# Put line breaks between paragraphs on a separate line.
|
||||||
|
text = re.sub(r'(?mu)</(p|title)>\s*<empty-line/>', r'</\1>\n<empty-line/>', text)
|
||||||
|
text = re.sub(r'(?mu)<empty-line/>\s*<p>', '<empty-line/>\n<p>', text)
|
||||||
|
|
||||||
# Remove empty sections.
|
# Remove empty sections.
|
||||||
text = re.sub(r'(?mu)<section>\s*</section>', '', text)
|
text = re.sub(r'(?mu)<section>\s*</section>', '', text)
|
||||||
# Clean up sections starts and ends.
|
# Clean up sections starts and ends.
|
||||||
@ -99,15 +106,6 @@ class FB2MLizer(object):
|
|||||||
text = re.sub(r'(?mu)<section>\s*', '<section>\n', text)
|
text = re.sub(r'(?mu)<section>\s*', '<section>\n', text)
|
||||||
text = re.sub(r'(?mu)\s*</section>', '\n</section>', text)
|
text = re.sub(r'(?mu)\s*</section>', '\n</section>', text)
|
||||||
text = re.sub(r'(?mu)</section>\s*', '</section>\n', text)
|
text = re.sub(r'(?mu)</section>\s*', '</section>\n', text)
|
||||||
# Put the section following a section on a separate line.
|
|
||||||
text = re.sub(r'(?mu)</section>\s*<section>', '</section>\n<section>', text)
|
|
||||||
|
|
||||||
if self.opts.insert_blank_line:
|
|
||||||
text = re.sub(r'(?mu)</p>', '</p><empty-line/>', text)
|
|
||||||
|
|
||||||
# Put line breaks between paragraphs on a separate line.
|
|
||||||
text = re.sub(r'(?mu)</(p|title)>\s*<empty-line/>', r'</\1>\n<empty-line/>', text)
|
|
||||||
text = re.sub(r'(?mu)<empty-line/>\s*<p>', '<empty-line/>\n<p>', text)
|
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user