I'm now trying to figure out how sections are created, I guess each
block level HTML tag is a section?
I think the kindle previewer cli must be able to "see" the book HTML since it could ignore hidden tags and find the css rules of a tag. The style rules are tricky to implement, maybe using a headless browser?
Here is the code:
https://github.com/xxyzz/kpfgen, it could only add the cover section for now.