Skip to main content

html2gemtext - A simple library for converting HTML to Gemtext

Introduction

html2gemtext is a small and simple library that provides code for converting HTML into the hypertext markup language of the Gemini project.

Installation

html2gemtext is available from pypi and can be installed with your package installer of choice.

With pip:

pip install html2gemtext

With uv:

uv add html2gemtext

Quick start

The library provides a single main conversion function called html_to_gemtext. It is passed a string that is the HTML you wish to convert, and the result is a string that is the resulting Gemtext.

A very minimal converter might look like:

import fileinput
from html2gemtext import html_to_gemtext

def convert() -> None:
    with fileinput.input() as html:
        print(html_to_gemtext("".join(html)))

While it is primarily intended as a library to be used from other Python code, it does contain a simple test command line tool, which can be accessed either via the Python -m switch, or depending on your environment, via the html2gemtext command. For example, given this content of a file called test.html:

<!doctype html>
<html lang="en">
  <head>
    <title>Test page</title>
  </head>

  <body>
    <p>
      Hello World! This is a test of the converter.
    </p>
    <p>
      <a href="https://www.example.com">This is a link</a> to an external website.
    </p>
  </body>
</html>

The html2gemtext command (or python -m html2gemtext) would produce:

Hello World! This is a test of the converter.

This is a link[1] to an external website.

=> https://www.example.com 1: https://www.example.com

See the main documentation for the full API.

Metadata

Release files for html2gemtext 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for html2gemtext 0.1.0
File Size Uploaded
html2gemtext-0.1.0.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for html2gemtext 0.1.0
File Interpreter ABI Platform
html2gemtext-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / html2gemtext-0.1.0.tar.gz

Download URL html2gemtext-0.1.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
84360f629c25c797d96921a2662a83777f09bf93e7f8cd876d37358567c66ab2
BLAKE2b-256 checksum
How to use checksums
2d1d7e842b0402c03eeb1b1c39bfd0dfe6d80feaeaf6f8689d10feceb6f9d74e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / html2gemtext-0.1.0-py3-none-any.whl

Download URL html2gemtext-0.1.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f13e3c9ff41edcdc8e2fa058deb5dbbe788b37eefbe1f27002f3add28c74bd72
BLAKE2b-256 checksum
How to use checksums
22c890e64e7bcd5fe382981a3dbe795f03909520c04cb2ccbf1da2046b3343e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

1.0.0

2 release files

This release

0.1.0 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page