Documentation ¶
Overview ¶
Package gemtext provides a variety of tools for processing gemtext files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderGemtext ¶
func RenderGemtext(p *GemtextPage) (string, error)
RenderGemtext takes a *GemtextPage and renders it into Gemtext.
func RenderHTML ¶
func RenderHTML(p *GemtextPage) (string, error)
RenderHTML renders a *GemtextPage p to a string containing html.
func RenderHeading ¶
func RenderHeading(obj GemtextObject) (string, error)
RenderHeading takes a GemtextObject and returns a gemini heading as a string or an error if the object is not a heading.
func RenderLink ¶
func RenderLink(obj GemtextObject) (string, error)
RenderLink takes a GemtextObject and returns a gemini link as a string or an error if the object is not a link.
Types ¶
type GemtextObject ¶
type GemtextObject struct { Type ObjectType Text string // Contains the text of the element. For a link this is the label. Literal string // Contains the line as it exists in the file Path string // Populated if object is a link Level int // Populated if object is a heading }
type GemtextObject represents a gemtext object.
func ParseHeading ¶
func ParseHeading(l string) (GemtextObject, error)
ParseHeading parses a gemtext heading, returns a HEADING GemtextObject if it is between levels 1-3 and TEXT otherwise.
func ParseLine ¶
func ParseLine(line string, isPreformatted bool) (GemtextObject, error)
ParseLine parses a gemtext line, and returns a GemtextObject representing it. "isPreformatted" takes a true if the line is in a preformatted block, else otherwise.
func ParseLink ¶
func ParseLink(l string) (GemtextObject, error)
ParseLink takes a gemini link as a string and returns a GemtextObject and an error.
type GemtextPage ¶
type GemtextPage []GemtextObject
type GemtextPage represents a gemtext page. It is equivalent to a slice of GemtextObjects.
func ParsePage ¶
func ParsePage(p string) (GemtextPage, error)
ParsePage takes a string containing the contents of a gemtext page and returns a GemtextPage.
type ObjectType ¶
type ObjectType int64
const ( TEXT ObjectType = iota LINK PREFORMATTED_TOGGLE PREFORMATTED_TEXT HEADING LIST QUOTE )