Skip to main content

gemtext - A simple library for parsing the Gemtext markup language

Introduction

gemtext is a small and simple library that provides code for parsing the hypertext markup language of the Gemini project.

Installation

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

With pip:

pip install gemtext

With uv:

uv add gemtext

Quick start

The library provides a single main parsing class called Gemtext. It is initialised with a body of gemtext and the content property provides a list of lines, typed with their parsed type, each having its own relevant properties.

A very minimal parser might look like this:

import fileinput
from gemtext import Gemtext

def parse_input() -> None:
    for gem_line in Gemtext("".join(fileinput.input())).content:
        print(f"{gem_line!r}")

The library contains a simple test command line tool, which can be accessed either via the Python -m switch, or depending on your environment, via the gemtext command. For example, given this content of a file called example.gmi:

# This is a heading

## This is a sub-heading

### This is a sub-sub-heading

=> gemini://davep.gemcities.com/ Dave's test capsule

> This is a deep and meaningful quote

```
Here is some pre-formatted text.

Here's some more of that text.
```

* One
* Two
* Three

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

$ gemtext example.gmi
Heading(content='This is a heading', level=1)
Paragraph(content='')
Heading(content='This is a sub-heading', level=2)
Paragraph(content='')
Heading(content='This is a sub-sub-heading', level=3)
Paragraph(content='')
Link(content="Dave's test capsule", uri='gemini://davep.gemcities.com/')
Paragraph(content='')
Quote(content='This is a deep and meaningful quote')
Paragraph(content='')
PreFormatted(content="Here is some pre-formatted text.\n\nHere's some more of that text.")
Paragraph(content='')
ListItem(content='One')
ListItem(content='Two')
ListItem(content='Three')

See the main documentation for the full API.

Release files for gemtext 1.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 gemtext 1.1.0
File Size Uploaded
gemtext-1.1.0.tar.gz 4.7 kB Details

Built distribution (wheel)

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

Total release size: 10.2 kB

Release files / gemtext-1.1.0.tar.gz

Download URL gemtext-1.1.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d8e0d89994c3d462c416886280b2ff3abfbcd57e3230b8b449bc7fee3b7c3535
BLAKE2b-256 checksum
How to use checksums
5d0e42d7dba3d43ba12565838d674fecee40db12cd15be92ac58a7309bea7218
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","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 / gemtext-1.1.0-py3-none-any.whl

Download URL gemtext-1.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87483b8c4a99f70fb3bb59fe6c05398de7a50fd234ae40ff25be843dda814e56
BLAKE2b-256 checksum
How to use checksums
92d76ab676a86f5a2642925e82cc0dd0d5608a759b171c17e10ae6a2a655e3f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","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

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.1.0

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