Documentation ¶
Index ¶
- func Render(in string, stylePath string) (string, error)
- func RenderBytes(in []byte, stylePath string) ([]byte, error)
- func RenderWithEnvironmentConfig(in string) (string, error)
- type TermRenderer
- type TermRendererOption
- func WithAutoStyle() TermRendererOption
- func WithBaseURL(baseURL string) TermRendererOption
- func WithColorProfile(profile termenv.Profile) TermRendererOption
- func WithEmoji() TermRendererOption
- func WithEnvironmentConfig() TermRendererOption
- func WithPreservedNewLines() TermRendererOption
- func WithStandardStyle(style string) TermRendererOption
- func WithStylePath(stylePath string) TermRendererOption
- func WithStyles(styles ansi.StyleConfig) TermRendererOption
- func WithStylesFromJSONBytes(jsonBytes []byte) TermRendererOption
- func WithStylesFromJSONFile(filename string) TermRendererOption
- func WithWordWrap(wordWrap int) TermRendererOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderBytes ¶
RenderBytes initializes a new TermRenderer and renders a markdown with a specific style.
func RenderWithEnvironmentConfig ¶ added in v0.2.0
RenderWithEnvironmentConfig initializes a new TermRenderer and renders a markdown with a specific style defined by the GLAMOUR_STYLE environment variable.
Types ¶
type TermRenderer ¶
type TermRenderer struct {
// contains filtered or unexported fields
}
TermRenderer can be used to render markdown content, posing a depth of customization and styles to fit your needs.
func NewTermRenderer ¶
func NewTermRenderer(options ...TermRendererOption) (*TermRenderer, error)
NewTermRenderer returns a new TermRenderer the given options.
func (*TermRenderer) Close ¶
func (tr *TermRenderer) Close() error
Close must be called after writing to TermRenderer. You can then retrieve the rendered markdown by calling Read.
func (*TermRenderer) Render ¶
func (tr *TermRenderer) Render(in string) (string, error)
Render returns the markdown rendered into a string.
func (*TermRenderer) RenderBytes ¶
func (tr *TermRenderer) RenderBytes(in []byte) ([]byte, error)
RenderBytes returns the markdown rendered into a byte slice.
type TermRendererOption ¶
type TermRendererOption func(*TermRenderer) error
A TermRendererOption sets an option on a TermRenderer.
func WithAutoStyle ¶ added in v0.2.0
func WithAutoStyle() TermRendererOption
WithAutoStyle sets a TermRenderer's styles with either the standard dark or light style, depending on the terminal's background color at run-time.
func WithBaseURL ¶
func WithBaseURL(baseURL string) TermRendererOption
WithBaseURL sets a TermRenderer's base URL.
func WithColorProfile ¶ added in v0.2.0
func WithColorProfile(profile termenv.Profile) TermRendererOption
WithColorProfile sets the TermRenderer's color profile (TrueColor / ANSI256 / ANSI).
func WithEmoji ¶ added in v0.3.0
func WithEmoji() TermRendererOption
WithEmoji sets a TermRenderer's emoji rendering.
func WithEnvironmentConfig ¶ added in v0.2.0
func WithEnvironmentConfig() TermRendererOption
WithEnvironmentConfig sets a TermRenderer's styles based on the GLAMOUR_STYLE environment variable.
func WithPreservedNewLines ¶ added in v0.4.0
func WithPreservedNewLines() TermRendererOption
WithPreservedNewlines preserves newlines from being replaced.
func WithStandardStyle ¶
func WithStandardStyle(style string) TermRendererOption
WithStandardStyle sets a TermRenderer's styles with a standard (builtin) style.
func WithStylePath ¶
func WithStylePath(stylePath string) TermRendererOption
WithStylePath sets a TermRenderer's style from stylePath. stylePath is first interpreted as a filename. If no such file exists, it is re-interpreted as a standard style.
func WithStyles ¶
func WithStyles(styles ansi.StyleConfig) TermRendererOption
WithStyles sets a TermRenderer's styles.
func WithStylesFromJSONBytes ¶
func WithStylesFromJSONBytes(jsonBytes []byte) TermRendererOption
WithStylesFromJSONBytes sets a TermRenderer's styles by parsing styles from jsonBytes.
func WithStylesFromJSONFile ¶
func WithStylesFromJSONFile(filename string) TermRendererOption
WithStylesFromJSONFile sets a TermRenderer's styles from a JSON file.
func WithWordWrap ¶
func WithWordWrap(wordWrap int) TermRendererOption
WithWordWrap sets a TermRenderer's word wrap.