gemtext

package
v0.0.0-...-e8e1271 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2025 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package gemtext implements shared logic related to gemtext files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FeedTranslator

type FeedTranslator struct {

	// Required. When interpreting links from the gemlog, all links will be
	// interpreted as being relative to this URL.
	BaseURL *url.URL

	// Optional strings to use in the top-level 'author' field of the resulting
	// feed.
	AuthorName, AuthorEmail string
}

FeedTranslator is used to translate a gemtext file, interpreted as a gemlog, into an RSS, Atom, or JSON feed.

func (FeedTranslator) ToAtom

func (t FeedTranslator) ToAtom(to io.Writer, from io.Reader) error

ToAtom translates the input gemtext document into an Atom feed.

func (FeedTranslator) ToJSON

func (t FeedTranslator) ToJSON(to io.Writer, from io.Reader) error

ToJSON translates the input gemtext document into an JSON feed.

func (FeedTranslator) ToRSS

func (t FeedTranslator) ToRSS(to io.Writer, from io.Reader) error

ToRSS translates the input gemtext document into an RSS feed.

type HTML

type HTML struct {
	Title string
	Body  string
}

HTML contains the result of a translation from gemtext. The Body will be the translated body itself, and Title will correspond to the first primary header of the gemtext file, if there was one.

type HTMLTranslator

type HTMLTranslator struct {
	// RenderHeading, if given can be used to override how headings are
	// rendered. The level indicates which heading level is being rendered: 1,
	// 2, or 3.
	RenderHeading func(w io.Writer, level int, text string) error

	// RenderLink, if given, can be used to override how links are rendered.
	RenderLink func(w io.Writer, url, label string) error
}

HTMLTranslator is used to translate a gemtext file into equivalent HTML DOM elements.

func (HTMLTranslator) Translate

func (t HTMLTranslator) Translate(src io.Reader) (HTML, error)

Translate will read a gemtext file from the Reader and return it as an HTML document.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL