Code Monkey home page Code Monkey logo

openepub's Introduction

openepub

Python library to interact with EPUB files.

openepub's People

Contributors

sakolkar avatar

Stargazers

 avatar JZ avatar

Watchers

 avatar

openepub's Issues

Error Parsing Package File on Windows

Type: Defect

Affects versions <=0.0.6

Background

When performing path.read_text() through the zipfile standard library a UnicodeDecodeError is raised. The zipfile library uses io.text_encoding() which seems to return locale most of the time. On Windows, this locale encoding turns into cp1252 which works sometimes for decoding the .opf file. But for languages like Japanese, oftentimes there are characters not in the cp1252 character set.

Eg.

>>> c[460:500].decode("utf8")
' id="author_0">Hakuchō Masamune</dc:cre'

>>> c[460:500].decode("cp1252", "replace")
' id="author_0">Hakuch� Masamune</dc:cre'

This leads to an error like this:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/lib/python3.10/encodings/cp1252.py", line 15, in decode
    return codecs.charmap_decode(input,errors,decoding_table)
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 482: character maps to <undefined>

Task

Specify encoding utf-8 so that on Windows it doesn't default into using cp1252.

Spaces getting stripped from parsed files.

Hey there!

In issue LuteOrg/lute-v3#344, there's an image showing how spaces are getting stripped during epub import. e.g., Here's a screenshot of the source epub:

image

Here's how it appears in Lute:

image

Here's the actual source in the zipped epub html:

<p class="Clanek1"><span lang="CS">Odpovědi na tyto a mnohé další otázky hledá v novém senzačním životopise
nazvaném </span><span lang="CS" class="calibre8">Život a lži Albuse Brumbála</span><span lang="CS"> Rita Holoubková. Exkluzivní rozhovor s ní přináší Betty Braithwaiteová
na straně 13.</span></p>

Ideally, the above snippet would be extracted as:

Odpovědi na tyto a mnohé další otázky hledá v novém senzačním životopise nazvaném Život a lži Albuse Brumbála Rita Holoubková. Exkluzivní rozhovor s ní přináší Betty Braithwaiteová na straně 13.

Does this seem like it's possible? Cheers!

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.