Skip to main content

Build text/gemini files from Python

Project description

gemini_builder

This Python package makes creation of Gemini text documents for Project Gemini a little easier.

To create a document, instantiate the Page class and add lines using the appropriate methods. Finally, you can convert the page to a string, print it, etc.

Methods

The following methods are used to add content to the page:

add_raw_line(raw_line)

Add any text as a line. Be cautious or you will screw everything up.

add_text(line=None)

Add normal text as a line. Can also be used to add an empty line.

add_heading(text, level=1)

Add a heading line. You can provide a level of 1, 2 or 3.

add_link(url, label=None)

Add a link line. The URL must already be properly quoted.

add_quote(quote)

Add a quote line.

add_list(items)

Add a list. The items argument should be an iterable that returns strings.

add_preformatted_lines(preformatted_lines, alt_text=None):

Add a block of preformatted lines. The preformatted_lines argument should be an iterable that returns strings. The optional alt_text argument will be added to the opening toggle line if present.

Exceptions

The following exceptions can be thrown:

GeminiBuilderException

Base class for all exceptions. Not instantiated.

InvalidHeadingLevelException

You tried to add a heading with a level that is not 1, 2 or 3.

NotIterableException

You tried to add a list but provided a non-iterable argument.

InvalidTextLineException

You provided a text line that starts with one of the reserved characters. Use add_raw_line to add any raw content.

PreformattedLineCannotStartLikeThisException

One of your pre-formatted lines begins with the reserved sequence for preformatted lines.

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

gemini_builder-0.1.0.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

gemini_builder-0.1.0-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

Supported by

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