markdown

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT, Unlicense Imports: 14 Imported by: 5

Documentation

Overview

Package markdown transforms markdown text into gio richtext.

Index

Constants

View Source
const MetadataURL = "url"

MetadataURL is the metadata key that the parser will set for hyperlinks detected within the markdown.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DefaultFont   font.Font
	MonospaceFont font.Font
	// Defaults to 12 if unset.
	DefaultSize unit.Sp
	// If unset, each level will be 1.2 times larger than the previous.
	H1Size, H2Size, H3Size, H4Size, H5Size, H6Size unit.Sp
	// Defaults to black.
	DefaultColor color.NRGBA
	// Defaults to blue.
	InteractiveColor color.NRGBA
}

Config defines settings used by the renderer.

type Renderer

type Renderer struct {

	// Config defines how the various markdown elements are presented.
	// If left as the zero value, sane defaults will be used.
	Config Config
	// contains filtered or unexported fields
}

Renderer can transform source markdown into Gio richtext. Hyperlinks will result in text that has the URL set as span metadata with key MetadataURL.

func NewRenderer

func NewRenderer() *Renderer

NewRenderer creates a ready-to-use markdown renderer.

func (*Renderer) Render

func (r *Renderer) Render(src []byte) ([]richtext.SpanStyle, error)

Render transforms the provided src markdown into gio richtext using the fonts and styles defined by the given theme.

Jump to

Keyboard shortcuts

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