raiju / phpMobi

An experimental Mobipocket file creator in PHP
Other
128 stars 32 forks source link

Text indent on paragraphs #7

Closed FattusMannus closed 10 years ago

FattusMannus commented 10 years ago

Kindles seem to add an indent to the start of each paragraph; when parsing articles from the web, the class seems to create a lot of paragraphs so a document has an indent on almost every line.

I have searched online and it seems to be fixable with css text-indent. I have tried to apply this inline where the paragraphs are generated. I have tried the options text-indent:0 and text-indent:1px but neither of these seem to have an effect

Have you seen this issue before and could you advise on how to address it?

Thanks Andrew

raiju commented 10 years ago

Sorry for the late reply. No I don't remember seeing that problem, but it was quite a while back since I did this... Hmm, I'll take a look at it, but I'm afraid I won't be able to do it right away. I'm a bit busy at the moment, so won't be able to look at/test the code in the next two weeks.

Can you replicate the problem when building the document using the "normal" API (not parsing from a webpage, but by using a MobiFile object and using appendParagraph?

raiju commented 10 years ago

Oh, and which Kindle is this happening on?

FattusMannus commented 10 years ago

It's happening on the original kindle keyboard. Research I've done says it's default for paragraphs

The issue seems to be related to OnlineArticle. If I do a post processing step, replacing all

tags in the $article variable with

, then I see no indent at all.

raiju commented 10 years ago

I've been looking around, and as you said this problem can't be solved nicely: it's a default for all Kindles, and files in the original MOBI format do not support custom styling through CSS. As far as I can see, there are two ways to solve the problem:

  1. Replace all <p> tags by <div> tags (adding a height attribute with a CSS-like value - for example, 1em - should add a margin above the tag, probably necessary to keep things readable).
  2. Implement the KF8 format (Amazon's new format, see http://wiki.mobileread.com/wiki/KF8). This would require quite a a lot of work to implement, and is outside of this project's scope.