sisyphus

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: BSD-2-Clause Imports: 10 Imported by: 0

README

sisyphus

convert gemtext to html/markdown

(api, interfaces, cli tool - everything is likely to change drastically 😂

cli usage

create a markdown readme from gemtext:

$ sisyphus -f markdown <README.gmi >README.md

convert gemtext to html:

$ sisyphus <index.gmi >index.html

from go

// html
sisyphus.Cook(os.Stdin, os.Stdout, &sisyphus.Html{})

// markdown
sisyphus.Cook(os.Stdin, os.Stdout, &sisyphus.Markdown{})

// convert from a string
sisyphus.Convert("=> somewhere a link", &sisyphus.Html{})

// hooks
flavor := &sisyphus.Html{}
flavor.OnLink(".jpg", hook)

installation

go
go install blekksprut.net/sisyphus/cmd/sisyphus@latest
arch linux

sisyphus is available as a package in the AUR

it can be installed with an AUR helper (e.g. yay):

$ yay -S sisyphus

Documentation

Index

Constants

View Source
const Version = "0.4.2"

Variables

This section is empty.

Functions

func Convert added in v0.0.8

func Convert(gmi string, flavor Flavor) string

func Cook added in v0.0.8

func Cook(r io.Reader, w io.Writer, flavor Flavor)

func Safe added in v0.1.1

func Safe(raw string) string

Types

type Flavor

type Flavor interface {
	Open() string
	Close() string
	ListItem(string) string
	Header(int, string) string
	Link(string, string) string
	Pre(string) string
	Quote(string) string
	Text(string) string

	SetState(State) string
	GetState() State

	OnLink(string, LinkHook)
	OnQuote(QuoteHook)
	OnOpen(Hook)
	OnClose(Hook)

	Aspeq(string, bool) LinkHook
	Wrap(string)
}

type Hook added in v0.3.0

type Hook func() string

type Html

type Html struct {
	Self      string
	State     State
	LinkHooks map[string]LinkHook
	QuoteHook QuoteHook
	OpenHook  Hook
	CloseHook Hook
	Greentext bool
}

func (*Html) Aspeq added in v0.0.7

func (html *Html) Aspeq(prefix string, useBase bool) LinkHook

func (*Html) Close added in v0.2.0

func (html *Html) Close() string

func (*Html) GetState added in v0.0.6

func (html *Html) GetState() State

func (*Html) Header

func (html *Html) Header(level int, text string) string
func (html *Html) Link(url string, text string) string

func (*Html) ListItem

func (html *Html) ListItem(text string) string

func (*Html) OnClose added in v0.3.1

func (html *Html) OnClose(hook Hook)
func (html *Html) OnLink(rule string, hook LinkHook)

func (*Html) OnOpen added in v0.3.1

func (html *Html) OnOpen(hook Hook)

func (*Html) OnQuote added in v0.3.1

func (html *Html) OnQuote(hook QuoteHook)

func (*Html) Open added in v0.2.0

func (html *Html) Open() string

func (*Html) Pre

func (html *Html) Pre(text string) string

func (*Html) Quote added in v0.0.6

func (html *Html) Quote(text string) string

func (*Html) SetState added in v0.0.6

func (html *Html) SetState(state State) string

func (*Html) Text added in v0.0.3

func (html *Html) Text(text string) string

func (*Html) Wrap added in v0.2.0

func (html *Html) Wrap(tag string)

type LinkHook added in v0.3.1

type LinkHook func(uri string, text string, match string) string

type Markdown

type Markdown struct {
	State State

	LinkHooks map[string]LinkHook
	QuoteHook QuoteHook
	OpenHook  Hook
	CloseHook Hook
}

func (*Markdown) Aspeq added in v0.3.6

func (md *Markdown) Aspeq(prefix string, useBase bool) LinkHook

func (*Markdown) Close added in v0.2.0

func (md *Markdown) Close() string

func (*Markdown) GetState added in v0.0.6

func (md *Markdown) GetState() State

func (*Markdown) Header

func (md *Markdown) Header(level int, text string) string
func (md *Markdown) Link(url string, text string) string

func (*Markdown) ListItem

func (md *Markdown) ListItem(text string) string

func (*Markdown) OnClose added in v0.3.1

func (md *Markdown) OnClose(hook Hook)
func (md *Markdown) OnLink(rule string, hook LinkHook)

func (*Markdown) OnOpen added in v0.3.1

func (md *Markdown) OnOpen(hook Hook)

func (*Markdown) OnQuote added in v0.3.1

func (md *Markdown) OnQuote(hook QuoteHook)

func (*Markdown) Open added in v0.2.0

func (md *Markdown) Open() string

func (*Markdown) Pre

func (md *Markdown) Pre(text string) string

func (*Markdown) Quote added in v0.0.6

func (md *Markdown) Quote(text string) string

func (*Markdown) SetState added in v0.0.6

func (md *Markdown) SetState(state State) string

func (*Markdown) Text added in v0.0.3

func (md *Markdown) Text(text string) string

func (*Markdown) Wrap added in v0.3.1

func (md *Markdown) Wrap(s string)

type QuoteHook added in v0.3.1

type QuoteHook func(text string) string

type State added in v0.0.6

type State int
const (
	None State = iota + 1
	Text
	List
	Pre
	Quote
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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