FB2 Input: use the <p> 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)

This commit is contained in:
Kovid Goyal 2023-08-26 10:14:57 +05:30
parent 18d0422203
commit 170a6fd64f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 1 deletions

View File

@ -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; }
</style>

View File

@ -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 <p> 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'))