gmi2html

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: 0BSD Imports: 8 Imported by: 1

README

gmi2html

Library for converting Gemtext to HTML

Based on adamcleod/gmi2html.

This is used for fishbb in the conext of post bodies and has some configuration options that you may find useful.

Examples

package main

import (
    "fmt"
    "os"
    "git.sr.ht/~aw/gmi2html"
)

func main() {
    // simple conversion with default values
    html := gmi2html.ConvertString("#hello\n=> https://google.com world")
    fmt.Println(html)
    // initialization and configuration
    r := gmi2html.NewReader(os.stdin)
    r.NestedBlocks = true
    r.WriteHTML(os.stdout)
}

Documentation

Overview

gmi2html provides tools to convert gemini's hypertext format (aka "gemtext") into HTML.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertString

func ConvertString(in string) string

ConvertString converts a gemtext string to an HTML string using the default configuration

Types

type GeminiReader added in v0.1.2

type GeminiReader struct {

	// NestedBlocks is a non-standard extension which allows blockquotes to
	// nest gemtext.
	// Specifically, this causes the formal grammer to change to:
	// quote-line = ">" gemtext-line
	// default false.
	NestedBlocks bool

	// AllowedSchemes is a list of allowed URL schemes to turn into links.
	// Default is http, https, gemini and mailto.
	AllowedSchemes []string

	// Apply this filter to all the outputted text after processing lines. By
	// default, html.EscapeString.  Does not apply to HTML attributes or text in
	// preformatted blocks.
	FilterText func(string) string
	// contains filtered or unexported fields
}

func NewReader added in v0.1.2

func NewReader(r io.Reader) *GeminiReader

NewReader constructs a new Gemtext reader.

func (*GeminiReader) HTMLString added in v0.1.3

func (gmi *GeminiReader) HTMLString() string

/ HTMLString reads the gemini document and returns an HTML string

func (*GeminiReader) WriteHTML added in v0.1.2

func (gmi *GeminiReader) WriteHTML(w io.Writer) error

Convert reads from a stream of gemtext and writes to the output writer.

Jump to

Keyboard shortcuts

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