imgurbot12 / pypub Goto Github PK
View Code? Open in Web Editor NEWThis project forked from wcember/pypub
Python library to programatically create epub files
License: MIT License
This project forked from wcember/pypub
Python library to programatically create epub files
License: MIT License
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.
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.
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!
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>
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>
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.
When I open the example epub I get a message on the first page:
“This page contains the following errors:error on line 4 at column 62: Entity 'nbsp' not defined”
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.