Htmlbook to Docx
A very opinionated htmlbook to docx converter, providing formatting that is similar to what a "manuscript" submission docx should look like.
This should work for most "run of the mill" prose documents.
Why Htmlbook?
For one thing, there are asciidoctor templates for it, but beyond that, compared to many "book-like" HTML outputs, it's relatively clean in terms of its HTML markup. This makes processing into docx both simpler and more reliable.
Installation and Usage
This tool can be installed via pip:
pip install htmlbook-docx
Then, to convert a given HTML file, simply run:
htmlbook2docx FILE
Contributing
I used this as a pilot project for trying uv
over poetry, so:
- Install
uv(links to docs) - Clone the repo
- Run
uv sync, which will create the virtual environment and get the packages going. - Hack away.
Quirks
Some quirks to keep in mind:
<code>tags are rendered in small caps; this is an accidental feature of the project I wrote this tool to solve for.- There are a bunch of idiosyncratic styles included in the defaults; feel free to use them, but mostly they are for the aforementioned project and can be safely ignored.
- If you have styles (classes) on your paragraphs that aren't present in
apply_manuscript_defaults, the build will fail. Someday, maybe, I'll make that pluggable. - While there is handling for definition lists, there is not currently handling for ordered or unordered lists. If these are present, instead of silently failing, the script should log the error to the terminal. This should be true for any "missed content."
To Do
Things yet to do:
- Handle more or all expected htmlbook tags
- Better style handling for unexpected classes
- User-provided styling for various classes (or better: create an "empty" style on-the-fly that the user can then modify inside Word or Libreoffice)
- Actually write tests. Whoops.
Metadata
Release files for htmlbook-docx 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| htmlbook_docx-0.2.0.tar.gz | 23.2 kB | Without provenance | Details for htmlbook_docx-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| htmlbook_docx-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for htmlbook_docx-0.2.0-py3-none-any.whl |
Total release size: 29.7 kB
Release files / htmlbook_docx-0.2.0.tar.gz
| Download URL | htmlbook_docx-0.2.0.tar.gz |
|---|---|
| Size | 23.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79d6aa79d912047489909b8fc2507a18e61260043fa439c97262d6e8c9c75adc
|
|
BLAKE2b-256 checksum How to use checksums |
6f93b9a8459768c4098c0f4f123944caeea219aa84cb19cfd9f1d809fb9835a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / htmlbook_docx-0.2.0-py3-none-any.whl
| Download URL | htmlbook_docx-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a9f393ad6b4e2cf65187e4fef62bded78f55e2915975b19dc47f3a997725988
|
|
BLAKE2b-256 checksum How to use checksums |
8c97b97765682c78beb425cdcb89a308a34d0075aa7a8fa65490450378c0f189
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Security for htmlbook-docx 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.