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 .convert 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.

Download files

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

Source Distribution

html2gemtext-0.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

html2gemtext-0.0.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file html2gemtext-0.0.1.tar.gz.

File metadata

  • Download URL: html2gemtext-0.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for html2gemtext-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b2c9047d3b54ce2eba3849ca23a9dc2bff14072351def8df3640eb297564d15b
MD5 fc4bf63928851c56ec735d239e8c419d
BLAKE2b-256 57020444932f062fe0ef2c9c61d0997a4c11f2b44ba0c5ecbfa323a64777763b

See more details on using hashes here.

File details

Details for the file html2gemtext-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: html2gemtext-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for html2gemtext-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8119df9d5a4d0095414c35b12ac542d7e0b57ea0842ea7e964e81da7bfebc4a
MD5 39e8856b001c93a50a45f481220dc854
BLAKE2b-256 316964f7b0f22b89aeaba33d614eca87084308cf1083722a60284efa18123f14

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