jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.82k stars 3.39k forks source link

writer for AZW3 (Kindle native format) #1865

Open ousia opened 9 years ago

ousia commented 9 years ago

@jgm, I wonder whether a writer for the Kindle native format could be added to issue #1852.

jgm commented 9 years ago

I hadn't heard of that. Nice idea. As far as I can see, it's not too different from EPUB. For reference: http://kindlegen.s3.amazonaws.com/AmazonKindlePublishingGuidelines.pdf

I don't see myself getting to this in the near future, but someone else might want to take on the project, starting with a refactoring of the EPUB writer code to make it more modular, so we can re-use common bits.

cmal commented 6 years ago

looking forward to this

lachrimae commented 6 years ago

Hey, I intend to start work on this and I haven't contributed before. What documentation would be key for understanding the interface the writer will have to implement? What are the most important modules it will interact with? I'm going to model the AZW3 writer off of the EPUB writer, so some things will be obvious, but any advice would be appreciated as well.

mb21 commented 6 years ago

The EPUB writer is somewhat special in that it basically calls the HTML writer and does some pre- and post-processing and then zips everything. If EPUB and AZW3 are very, very similar, it might even make sense to implement azw3 as an extension to the EPUB writer.

Personally, I would probably convert to epub and then use calibre of KindleGen to go to AZW3, instead of writing a pandoc writer, but maybe there are use-cases which I'm not considering...

jgm commented 6 years ago

I should also say that (as the author of the EPUB writer) I don't think the code quality is very good. (It should be broken down into smaller units, and types should be used more.) But as far as the interface goes, it should give you a good idea of what needs to come in and go out!

Note that everything happens in an instance of PandocMonad, which gives you functions for issuing warnings, fetching resources, and putting resources in a "media bag." Studying what the EPUB writer does should show you how this works, but of course we're happy to answer any questions.

As @mb21 says, if there are just a few changes from EPUB, we could consider adding an extension to EPUB (and maybe HTML) so we wouldn't actually need a completely new module.

Mauro Bieg notifications@github.com writes:

The EPUB writer is somewhat special in that it basically calls the HTML writer and does some pre- and post-processing and then zips everything. If EPUB and AZW3 are very, very similar, it might even make sense to implement azw3 as an extension to the EPUB writer.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/jgm/pandoc/issues/1865#issuecomment-407881030