Skip to main content

Convert GhBook-style HTML book files into plain text.

Project description

ghbook

Python library and CLI for converting GhBook-style HTML book files to clean .txt output while preserving book/chapter structure, page separators, and footnotes.

Install

pip install ghbook

Use as CLI

ghbook path/to/book.htm
ghbook path/to/book.htm path/to/output.txt

Use as library

from ghbook import convert_file

convert_file("path/to/book.htm", "path/to/output.txt")

Supported HTML patterns

Example HTML files are included in htmlbooks/ to demonstrate these structures.

  • Book and chapter headings such as content_h2 / content_h3 are emitted with ## prefix.
  • Paragraph text is extracted from content_paragraph and content_text.
  • Page markers like ص: 531 are converted to PAGE_SEPARATOR:.
  • <hr class="content_hr"> with following content_note blocks are emitted as:
____________
<footnote text>

Main text is preserved as-is; footnotes are appended below the separator.

PyPI trusted publisher (GitHub Actions OIDC)

This repository is prepared for publishing to PyPI using a trusted publisher workflow at:

  • .github/workflows/publish.yml

Configure on PyPI

  1. Go to PyPI project settings for ghbook and open the publishing/trusted publisher section.
  2. Add a GitHub trusted publisher with:
    • Owner: Ciyoku
    • Repository: ghbook
    • Workflow filename: publish.yml
  3. Save.

Release

Tag and push a version tag to publish:

git tag v0.1.0
git push origin v0.1.0

The workflow builds the package and publishes it to PyPI using OIDC, without API tokens.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ghbook-0.1.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ghbook-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file ghbook-0.1.1.tar.gz.

File metadata

  • Download URL: ghbook-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ghbook-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5c102b6ba0e89bd34ea548bd84b818f7a307548874fa580637dff19a24cdb8a0
MD5 b2f84718b42ce9a7916feb3e6fd31124
BLAKE2b-256 4a6d62720383fa4ff35df601411b1396de88c4752ccd3e9c8318638492f08bf6

See more details on using hashes here.

File details

Details for the file ghbook-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ghbook-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ghbook-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15d22feb27d42beb5fb879bd679a4b48972cdf2bfae587b84a157fd2c4c48053
MD5 1a40645af6011629be8a71c6393a0122
BLAKE2b-256 acaa1e400091fce0c04a29d72ba0c698fa8b1b08e358e008e37653db6ac256a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page