Skip to content
forked from leotaku/mobi

This Go package implements writing KF8-style formatted MOBI and AZW3 books, with added support for vertical RTL text in Japanese books

License

Notifications You must be signed in to change notification settings

imploz/mobi-vertical

 
 

Repository files navigation

Go MOBI

Github Actions CI Go Report Card Go Reference

This package implements facilities to create KF8-formatted MOBI and AZW3 books. We also export the raw PalmDB writer and various PalmDoc, MOBI and KF8 components as subpackages, which can be used to implement other formats that build on these standards.

This fork

This fork was created from the original to add support for vertical right-to-left text (and also vertical left-to-right text for completeness). (in addition to support for horizontal RTL which seems to be in the code, though I haven't tested it and didn't modify it's behavior in this fork). This allows this library to generate japanese azw3 ebooks with the same text orientation as in typical Japanese printed novels to enjoy them on a Kindle reader.

Also, I added ExtraHead field to Book to allow adding e.g. extra styles directly to the generated html files.

Usage

In order to get vertical RTL text, use mobi.Book's RightToLeft=true and Vertical=true:

  mb := mobi.Book{
    // ...
    RightToLeft: true,
    Vertical:    true,
  }

In order to get emphasis markers from yomukaku work use the following for Book's

  mb := mobi.Book{
    // ...
    ExtraHead: `
      <style> 
        .emphasisDots {
          font-weight: normal;
          text-emphasis-style: dot;
          -webkit-text-emphasis-style: dot;
          }
      </style>`
  }

Possible improvements of this fork

It would probably be cleaner to introduce the necessary styles as CSS files and refer to them in each html file using Book.CSSFlows instead of this dirty yet easy hack in templating.go. The same goes for injecting e.g. the style for emphasisDots class via ExtraHead.

Known issues

  • Chapters are supported but subchapters are not
  • Old readers without KF8 are not supported (Kindle 1, 2 and DX)
  • Books without any text content are always malformed
  • Errors during template expansion result in a panic

References

Huge thanks to the authors of these resources.

License

MIT © Leo Gaskin 2020-2022

About

This Go package implements writing KF8-style formatted MOBI and AZW3 books, with added support for vertical RTL text in Japanese books

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.8%
  • Nix 0.2%