Giter VIP home page Giter VIP logo

pypub's People

Contributors

avalonv avatar celeduc avatar imgurbot12 avatar jenuk avatar mcepl avatar myusuf3 avatar pietroalbini avatar wcember 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

Watchers

 avatar  avatar

pypub's Issues

Inline styles

I have HTML that sets font size and text color using an inline style, but it doesn't make it to the EPUB.

<p style="color:blue; font-size:12px;">This is a paragraph.</p>

Similarly for list items:

<ol style="list-style-type: lower-alpha;"><li>​a list item</li></ol>

Should style attrs just be passed through unchanged? With the understanding that some may be ignored by some readers.

Cannot set custom cover images

When specifiying an own cover image, the programs runs into an exceptionj: RuntimeError: cannot render_chapter before begin.

The following script can be used to reproduce this issue (note that the file must be named cover.png).

import pypub

ebook = pypub.Epub(title="Test", cover="/home/user/cover.png")
c = pypub.create_chapter_from_html(html="<p>Test</p>".encode())
ebook.add_chapter(c)
ebook.create("test.epub")

This can be fixed by moving line 208 in builder.py before line 201. Using this approach will make sure that self.template is defined also when using a custom cover.

Getting an error trying to run the exemple code

Hi! When trying to run the example code, I get the following error, which seems to be tied to xml parsing:
"epub ValueError: ('unsupported token', Result(token=<XToken.FUNCTION: 8>, value=b'text()', lineno=0, position=9))"

Is the module perhaps incompatible with python 3.10?

Thank you very much for your hard work anyway!

Tables

When I start with HTML something like this:

<h2>Table</h2>
<table>
  <tr>
    <td>Cell one</td>
    <td>Cell two</td>
  </tr>
  <tr>
    <td>Cell three</td>
    <td>cell four</td>
  </tr>
</table>

I end up with

  <body>
    <h2>Table</h2>
    <p><br/>
    </p>
    <hr/>
  </body>

Style files added to "css_paths" get copied to the epub, but not included

For example:

css_path "path/to/my.css"
epub = pypub.Epub("title")
epub.css_paths = [css_path]
etc.

Will add the css file to the package:

  inflating: OEBPS/styles/my.css   
  inflating: OEBPS/styles/styles.css  

But not include it in the page HTML:

  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <link type="text/css" rel="stylesheet" href="styles/styles.css"/>
    <title>Test Title</title>
  </head>

Local images not handled correctly

Hi @imgurbot12,

great tool, helped me a lot! While working with it, I noticed a small bug:

When including local image files, the following exception occurs: AttributeError: '_io.BufferedReader' object has no attribute 'status'.

The following script can be used for reproducing this issue.

import pypub

html_content = """<p>This is a test</p><img src="file:///home/user/a.png">"""

ebook = pypub.Epub(title="Test")
c = pypub.create_chapter_from_html(html=html_content.encode())
ebook.add_chapter(c)
ebook.create("test.epub")`

The bug can be found in line 105 of factory.py. The problem is that in the case of local files, res does not have a res.status attribute but nevertheless contains the data as a BufferedReader. Uncommenting these two lines will make the example above work.

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.