A library for parsing gemtext (mimetype text/gemini) in python3.

Björn Wärmedal 2cab467aef Added method for getting the whole text line from the gemtext line class 2 years ago
gemtextparser 2cab467aef Added method for getting the whole text line from the gemtext line class 2 years ago
.gitignore 30f38c9d98 Initial commit 2 years ago
LICENSE 30f38c9d98 Initial commit 2 years ago
README.md cb77276325 Updated README 2 years ago
setup.py 2cab467aef Added method for getting the whole text line from the gemtext line class 2 years ago

README.md

gemtextparser

A library for parsing gemtext (mimetype text/gemini) in python3.

usage: gemtextparser [-h] [-f FILE]

A library and CLI tool for parsing and validating gemtext (mimetype text/gemini) in python3.

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  File to validate

As library:

import gemtextparser

parser = gemtextparser.GemtextParser()

line = gp.parseLine("# Some Gemtext string here.")

print(f"The line is of type {line.linetype.name} with the text '{line.text()}'.")

When used as a library it provides the developer with the following:

  • The LineType enum
  • The GemtextLine class, with the attributes linetype (a LineType enum) and line (the full line of text), as well as the methods linkURL (returns the linkURL for link lines, and None for other line types) and text (returns the link text or empty string for linklines, and the text of the line for other line types).
  • The parseLine and parseText methods, which return a GemtextLine object and an array of GemtextLine objects, respectively.