From 170a6fd64f97e1ffe2389391033e3ce4d3ed7b68 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 26 Aug 2023 10:14:57 +0530 Subject: [PATCH] FB2 Input: use the

tag for paragraphs that dont contain other block content. Fixes #2033074 [E-book viewer: Reference mode doesn't work with *.fb2 ebooks](https://bugs.launchpad.net/calibre/+bug/2033074) --- resources/templates/fb2.xsl | 2 +- src/calibre/ebooks/conversion/plugins/fb2_input.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/templates/fb2.xsl b/resources/templates/fb2.xsl index 4ff7b14490..695f4be544 100644 --- a/resources/templates/fb2.xsl +++ b/resources/templates/fb2.xsl @@ -55,7 +55,7 @@ .epigraph{width:75%; margin-left : 25%; font-style: italic;} - div.paragraph { text-indent: 2em; } + div.paragraph, p.paragraph { text-indent: 2em; margin-top: 0; margin-bottom: 0; } .subtitle { text-align: center; } diff --git a/src/calibre/ebooks/conversion/plugins/fb2_input.py b/src/calibre/ebooks/conversion/plugins/fb2_input.py index dae3137270..809b4ac77b 100644 --- a/src/calibre/ebooks/conversion/plugins/fb2_input.py +++ b/src/calibre/ebooks/conversion/plugins/fb2_input.py @@ -122,6 +122,12 @@ class FB2Input(InputFormatPlugin): for img in result.xpath('//img[@src]'): src = img.get('src') img.set('src', self.binary_map.get(src, src)) + + # make paragraphs

tags + for divp in result.xpath('//body/div[@class="paragraph"]'): + if not divp.xpath('descendant::div'): + divp.tag = 'p' + index = transform.tostring(result) with open('index.xhtml', 'wb') as f: f.write(index.encode('utf-8'))