From d7a4e10c6022d13a17f87ae304d4b6ff84e02c17 Mon Sep 17 00:00:00 2001
From: Andrey Efremov
Date: Tue, 8 Oct 2019 15:57:13 +0700
Subject: [PATCH] FB2 Output: Revert some changes in regular expressions due to
different behavior
---
src/calibre/ebooks/fb2/fb2ml.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/calibre/ebooks/fb2/fb2ml.py b/src/calibre/ebooks/fb2/fb2ml.py
index 5697f2262a..12dd539e53 100644
--- a/src/calibre/ebooks/fb2/fb2ml.py
+++ b/src/calibre/ebooks/fb2/fb2ml.py
@@ -81,22 +81,24 @@ class FB2MLizer(object):
# Condense empty paragraphs into a line break.
text = re.sub(r'(?mu)(?:\s*){3,}', '', text)
# Remove empty paragraphs.
- text = re.sub(r'(?mu)', '', text)
+ text = re.sub(r'(?mu)\s*', '', text)
# Put the paragraph following a paragraph on a separate line.
text = re.sub(r'(?mu)
\s*', '
\n', text)
# Clean up title endings.
text = re.sub(r'(?mu)\s+', '', text)
# Remove empty title elements.
- text = re.sub(r'(?mu)
', '', text)
+ text = re.sub(r'(?mu)\s*', '', text)
# Put the paragraph following a title on a separate line.
text = re.sub(r'(?mu)\s*', '\n
', text)
# Remove empty sections.
text = re.sub(r'(?mu)', '', text)
# Clean up sections starts and ends.
- text = re.sub(r'(?mu)\s*\s*', '\n\n', text)
- text = re.sub(r'(?mu)\s*\s*', '\n\n', text)
+ text = re.sub(r'(?mu)\s*', '\n', text)
+ text = re.sub(r'(?mu)\s*', '\n', text)
+ text = re.sub(r'(?mu)\s*', '\n', text)
+ text = re.sub(r'(?mu)\s*', '\n', text)
# Put the section following a section on a separate line.
text = re.sub(r'(?mu)\s*\n