wustho / epy

CLI Ebook (epub2, epub3, fb2, mobi) Reader
GNU General Public License v3.0
962 stars 52 forks source link

quote indentation #18

Open ratnamhof opened 3 years ago

ratnamhof commented 3 years ago

Hi wustho,

Once again I would like to congratulate you with this wonderful project. Very impressive indeed! For novels epy has by now become my principle epub reader ...

In addition it makes me very happy to see how actively you are maintaining it and adding new features with each release! The "bookmark" feature is a very valuable extension indeed (and I am fond of the dictionary search as well, although it is a bit older I believe)!

On another note: recently I stumbled upon the following code:

<p>paragraph1</p>
<blockquote class="calibre24">
<p>quote1<br class="calibre13"/>quote2</p>
</blockquote>
<p>paragraph2</p>
<p>paragraph3</p>

This is rendered as follows by epy:

paragraph1

    quote1

    quote2

    paragraph2

paragraph3

As can be seen also paragraph2 appears indented. I suppose this is the consequence of the use of the paragraph tag <p> inside the body of the blockquote tag, which results in an additional pass through HTMLtoLines.handle_data(), which in turn appends an extra incremental value to self.idinde that in the final rendering corresponds to the position of paragraph2. To me the easiest solution for this example seems to be to update self.idinde only when the tag encloses actual content, i.e. inside handle_data using:

    elif self.isinde and line:
        self.idinde.add(len(self.text)-1)

With the additional conditional on line the result was rendered as desired (for this example):

paragraph1

    quote1

    quote2

paragraph2

paragraph3

This is a tiny non-essential change, but perhaps you may like to take it along in some future update anyway.

Please feel free to ignore this post if you disagree or if you have a better solution ;)

Cheers, Happy user

wustho commented 3 years ago

Hey there, thanks so much mate... Appreciate your suggestion, that's very thorough of you... And totally agree with you, I will keep this in mind and try to implement it in next commit...

Seems like I haven't encounter enough blockquote to notice it... Thanks, cheers.