markup

package
v0.0.0-...-6513b37 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MentionType   = "mention"
	ReferenceType = "reference"
)

Variables

View Source
var Hyphenate = false

Hyphenate controls whether or not texts should have hyphens on wrap.

Functions

func FragmentImageSize

func FragmentImageSize(URL string, maxw, maxh int) (w, h int, round bool)

FragmentImageSize tries to parse the width and height encoded in the URL fragment, which is inserted by the markup renderer. A pair of zero values are returned if there is none. The returned width and height will be the minimum of the given maxes and the encoded sizes.

func Render

func Render(content text.Rich) string

func SubstringSegment

func SubstringSegment(rich text.Rich, seg text.Segment) text.Rich

SubstringSegment slices the given rich text.

Types

type MentionSegment

type MentionSegment struct {
	text.Segment
	text.Mentioner
}

MentionSegment is a type that satisfies both Segment and Mentioner.

type ReferenceSegment

type ReferenceSegment struct {
	text.Segment
	text.MessageReferencer
}

ReferenceSegment is a type that satisfies both Segment and MessageReferencer.

type RenderConfig

type RenderConfig struct {
	// NoMentionLinks, if true, will not render any mentions.
	NoMentionLinks bool

	// NoReferencing, if true, will not parse reference links and prefer
	// mentions.
	NoReferencing bool

	// SkipImages skips rendering any image markup. This is useful for widgets
	// that already render an outside image.
	SkipImages bool

	// AnchorColor forces all anchors to be of a certain color. This is used if
	// the boolean is true. Else, all mention links will not work and regular
	// links will be of the default color.
	AnchorColor struct {
		// contains filtered or unexported fields
	}
}

type RenderOutput

type RenderOutput struct {
	Markup     string
	Input      string // useless to keep parts, as Go will keep all alive anyway
	Mentions   []MentionSegment
	References []ReferenceSegment
}

RenderOutput is the output of a render.

func RenderCmplx

func RenderCmplx(content text.Rich) RenderOutput

RenderCmplx renders content into a complete output.

func RenderCmplxWithConfig

func RenderCmplxWithConfig(content text.Rich, cfg RenderConfig) RenderOutput

func (RenderOutput) URISegment

func (r RenderOutput) URISegment(uri string) text.Segment

Jump to

Keyboard shortcuts

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