Documentation
¶
Overview ¶
Package glamour lets you render markdown documents & templates on ANSI compatible terminals. You can create your own stylesheet or simply use one of the stylish defaults
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 WithChromaFormatter(formatter string) TermRendererOption
- func WithColorProfile(profile termenv.Profile) TermRendererOption
- func WithEmoji() TermRendererOption
- func WithEnvironmentConfig() TermRendererOption
- func WithInlineTableLinks(inlineTableLinks bool) TermRendererOption
- func WithOptions(options ...TermRendererOption) 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 WithTableWrap(tableWrap bool) 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 WithChromaFormatter ¶ added in v0.8.1
func WithChromaFormatter(formatter string) TermRendererOption
WithChromaFormatter sets a TermRenderer's chroma formatter used for code blocks.
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 WithInlineTableLinks ¶ added in v0.10.0
func WithInlineTableLinks(inlineTableLinks bool) TermRendererOption
WithInlineTableLinks forces tables to render links inline. By default,links are rendered as a list of links at the bottom of the table.
func WithOptions ¶ added in v0.8.1
func WithOptions(options ...TermRendererOption) TermRendererOption
WithOptions sets multiple TermRenderer options within a single TermRendererOption.
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 WithTableWrap ¶ added in v0.10.0
func WithTableWrap(tableWrap bool) TermRendererOption
WithTableWrap controls whether table content will wrap if too long. This is true by default. If false, table content will be truncated with an ellipsis if too long to fit.
func WithWordWrap ¶
func WithWordWrap(wordWrap int) TermRendererOption
WithWordWrap sets a TermRenderer's word wrap.
Directories
¶
Path | Synopsis |
---|---|
Package ansi handle conversion of markdown to pretty ANSI output on the terminal.
|
Package ansi handle conversion of markdown to pretty ANSI output on the terminal. |
internal
|
|
autolink
Package autolink provides a function to detect and format GitHub links into a more readable manner.
|
Package autolink provides a function to detect and format GitHub links into a more readable manner. |
Package styles provides default styles for the glamour package.
|
Package styles provides default styles for the glamour package. |