Giter VIP home page Giter VIP logo

mkepub's People

Contributors

anqxyr avatar elebow avatar gforcada avatar jnns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mkepub's Issues

Why is the menu at the end of the book?

First of all, thank you for the code.
I generated an .epub file and converted it to .mobi file with calibre and put it into kindle, I found that the directory is at the end of the document, how do I need to set it?

Writing UTF-8 error

I got that Error if i try to write utf-8 pages/chapters

Traceback (most recent call last):
  File "C:\Users\User\PycharmProjects\MyTests\make-epub.py", line 130, in <module>
    main()
  File "C:\Users\User\PycharmProjects\MyTests\make-epub.py", line 108, in main
    createEpub(novel, basePath, output)
  File "C:\Users\User\PycharmProjects\MyTests\make-epub.py", line 88, in createEpub
    book.add_page(title=chapter.name, content=chapter.content)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\mkepub\mkepub.py", line 96, in add_page
    self._write_page(page, content)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\mkepub\mkepub.py", line 157, in _write_page
    self._write(
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\mkepub\mkepub.py", line 153, in _write
    file.write(env.get_template(template).render(**data))
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u016b' in position 10051: character maps to <undefined

My workaround was to change mkepub.py@L:152
with open(str(self.path / path), 'w') as file:
to
with open(str(self.path / path), 'w', encoding='utf-8') as file:

Can you push a new release, please?

Hello! The fixes that were made since last release are still not available if you install the package through pip. Can you please bump the version?

Streaming interface and other small enhancements

I am trying to use mkepub in a project, but it lacks several features I need.

Main part is a file-like interface allowing to add a Page in the right position and add content later (when available).

Other enhancement I will need is Font Embedding.

I am implementing them locally and I believe I'm fully able to handle what I need.
Real question is: are You interested to a possible (set of) Pull Request?
I would like to contribute code back upstream, if possible.

Please let me know how I should proceed.

mkepub should have a changelog

https://keepachangelog.com details the benefits of having a changelog.

I'm happy to put one together for the post-1.0 releases, but I won't go to the effort without a prior go-ahead.

Having a changelog more or less implies some mechanism for keeping it up to date. I suggest placing a reminder in CONTRIBUTING.md and/or a PULL_REQUEST_TEMPLATE.md, which will be visible in the GitHub UI when a user opens a new PR.

mkepub cannot parse string in html. it instead adds in rubbish text

I have generated the ebook but when I try to open it in ebook readers like calibre and sigil. it cannot read the text inside.

Here's my code to create the epub:

book3 = mkepub.Book(title="test")
book3.add_page("chapter 1", str(soup.text))
book3.save('test3.epub')

and here's the html for it

<html>
 <body>
  <p>
   Chapter 1-2
  </p>
  <br/>
  <p>
   "Papa … . Papa … . "
  </p>
  <br/>
  <p>
   Michael Shen [1] heard a crisp but immature voice that seemed to be calling him . He moved his hands to cover his ears to drown out the voice but instead seemed to feel something soft . His reflex actions, honed from years of survival instincts, forced him to sit up quickly and take a quick look . One look and he was stunned .
  </p>
  <br/>
  <p>
   Where am I?
  </p>
  <br/>
  <p>
   Am I safe or have I somehow be magically transported to somewhere else?
  </p>
  <br/>
  <p>
   Michael Shen could vaguely recall that he was in a private charter boat . He was very happy when he found a King Crab caught in his crab trap . He slowly lifted up the crab trap and was about to bring it on board the boat, when a strong wave suddenly hit the boat . The impact forced Michael Shen overboard . As he fell into the water, he dimly heard the sound of a woman screaming, and someone diving into the water . Then all is dark and quiet .
  </p>
   “Perfect!” Michael nodded his head in great satisfaction . He was about to confirm this design when he hesitatingly asked the system, “[System], does the renovation includes designing the second floor of the building as well?”
  </p>
  <br/>
 </body>
</html>

and here's how it looks in a ebook reader.
image

Do you have any idea what I am doing wrong?

pip fails when building wheel

Thank you very much for building/publishing mkepub -

One minor error, when installing mkepub via pip, the setup.py script fails when building a wheel:

error log

$ python3 -m pip install mkepub
Collecting mkepub
  Using cached mkepub-1.2.tar.gz (5.8 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: jinja2 in ./venv/lib/python3.9/site-packages (from mkepub) (3.1.2)
Requirement already satisfied: MarkupSafe>=2.0 in ./venv/lib/python3.9/site-packages (from jinja2->mkepub) (2.1.3)
Building wheels for collected packages: mkepub
  Building wheel for mkepub (setup.py) ... error
  error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [42 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/mkepub
copying mkepub/mkepub.py -> build/lib/mkepub
copying mkepub/init.py -> build/lib/mkepub
creating build/lib/mkepub/templates
copying mkepub/templates/container.xml -> build/lib/mkepub/templates
copying mkepub/templates/page.xhtml -> build/lib/mkepub/templates
copying mkepub/templates/toc.xhtml -> build/lib/mkepub/templates
copying mkepub/templates/cover.xhtml -> build/lib/mkepub/templates
copying mkepub/templates/toc.ncx -> build/lib/mkepub/templates
copying mkepub/templates/package.opf -> build/lib/mkepub/templates
installing to build/bdist.macosx-10.9-x86_64/wheel
running install
running install_lib
creating build/bdist.macosx-10.9-x86_64
creating build/bdist.macosx-10.9-x86_64/wheel
creating build/bdist.macosx-10.9-x86_64/wheel/mkepub
copying build/lib/mkepub/mkepub.py -> build/bdist.macosx-10.9-x86_64/wheel/mkepub
copying build/lib/mkepub/init.py -> build/bdist.macosx-10.9-x86_64/wheel/mkepub
creating build/bdist.macosx-10.9-x86_64/wheel/mkepub/templates
copying build/lib/mkepub/templates/container.xml -> build/bdist.macosx-10.9-x86_64/wheel/mkepub/templates
copying build/lib/mkepub/templates/page.xhtml -> build/bdist.macosx-10.9-x86_64/wheel/mkepub/templates
copying build/lib/mkepub/templates/toc.xhtml -> build/bdist.macosx-10.9-x86_64/wheel/mkepub/templates
copying build/lib/mkepub/templates/cover.xhtml -> build/bdist.macosx-10.9-x86_64/wheel/mkepub/templates
copying build/lib/mkepub/templates/toc.ncx -> build/bdist.macosx-10.9-x86_64/wheel/mkepub/templates
copying build/lib/mkepub/templates/package.opf -> build/bdist.macosx-10.9-x86_64/wheel/mkepub/templates
running install_egg_info
running egg_info
writing mkepub.egg-info/PKG-INFO
writing dependency_links to mkepub.egg-info/dependency_links.txt
writing requirements to mkepub.egg-info/requires.txt
writing top-level names to mkepub.egg-info/top_level.txt
warning: Failed to find the configured license file 'LICENSE'
reading manifest file 'mkepub.egg-info/SOURCES.txt'
writing manifest file 'mkepub.egg-info/SOURCES.txt'
Copying mkepub.egg-info to build/bdist.macosx-10.9-x86_64/wheel/mkepub-1.2-py3.9.egg-info
running install_scripts
error: [Errno 2] No such file or directory: 'LICENSE'
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for mkepub
Running setup.py clean for mkepub
Failed to build mkepub
ERROR: Could not build wheels for mkepub, which is required to install pyproject.toml-based projects

The LICENSE file which gets referenced in setup.cfg is not included in the source distribution.

This happens for me when installing mkepub with:

  • pip 23.2
  • Python 3.9
  • macOS 12.6.3

As a proposed workaround, I'll submit a PR with a MANIFEST.in file added.

Note that a pip install works when the GitHub URL is referenced directly, i.e., not building through the latest PyPi release:

python3 -m pip uninstall git+https://github.com/anqxyr/mkepub

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.