Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdmonitionRenderer ¶
type AdmonitionRenderer struct {
// contains filtered or unexported fields
}
AdmonitionRenderer is a custom Blackfriday renderer that attempts to find admonition style markdown and render it
func (*AdmonitionRenderer) RenderNode ¶
func (r *AdmonitionRenderer) RenderNode(w io.Writer, node *bf.Node, entering bool, base bf.Renderer) bf.WalkStatus
RenderNode will render the node and try to find admonitions
type AnchorOption ¶
type AnchorOption func(r *AnchorRenderer)
AnchorOption defines the functional option type for the code rendering
func Classes ¶
func Classes(in ...string) AnchorOption
Classes is a list of classes that will be applied to the anchor. Default: []string{"anchor"}
func Content ¶
func Content(s string) AnchorOption
Content is what will be displayed. This can be any HTML code, or a simple char. Default: "#"
func IDPrefix ¶
func IDPrefix(s string) AnchorOption
IDPrefix is a prefix that will be put before the ID of the matching heading content. Although you can set it to "", that will duplicate IDs in your DOM, so it not a good practice. Always use a prefix. Default: "a-"
type AnchorRenderer ¶
AnchorRenderer contains the required metadata for proper code rendering
func (*AnchorRenderer) RenderNode ¶
RenderNode is a simple function that needs to be called at the right moment when rendering markdown. Note that the AnchorRenderer itself doesn't implement all the methods required to be considered a true renderer. This is by design.
type CodeOption ¶
type CodeOption func(r *CodeRenderer)
CodeOption defines the functional option type for the code rendering
func ChromaOptions ¶
func ChromaOptions(options ...html.Option) CodeOption
ChromaOptions allows to pass Chroma html.Option such as Standalone() WithClasses(), ClassPrefix(prefix)...
func ChromaStyle ¶
func ChromaStyle(s *chroma.Style) CodeOption
ChromaStyle is an option to directly set the style of the renderer using a chroma style instead of a string
func Style ¶
func Style(s string) CodeOption
Style is a function option allowing to set the style used by chroma Default : "monokai"
func WithoutAutodetect ¶
func WithoutAutodetect() CodeOption
WithoutAutodetect disables chroma's language detection when no codeblock extra information is given. It will fallback to a sane default instead of trying to detect the language.
type CodeRenderer ¶
type CodeRenderer struct { Autodetect bool ChromaOptions []html.Option Style *chroma.Style Formatter *html.Formatter }
CodeRenderer contains the required metadata for proper code rendering
func (*CodeRenderer) RenderWithChroma ¶
func (r *CodeRenderer) RenderWithChroma(w io.Writer, text []byte, data bf.CodeBlockData) error
RenderWithChroma will render the given text to the w io.Writer
type Option ¶
type Option func(r *Renderer)
Option defines the functional option type
func WithCodeHighlighting ¶
func WithCodeHighlighting(options ...CodeOption) Option
WithCodeHighlighting enables syntax highlighting using Chroma
func WithHeadingAnchors ¶
func WithHeadingAnchors(options ...AnchorOption) Option
WithHeadingAnchors enables anchor insertion for headings
type Renderer ¶
type Renderer struct { Base bf.Renderer // Base renderer, the one we will extend Highlighter *CodeRenderer Anchor *AnchorRenderer Admonition *AdmonitionRenderer }
Renderer extends a base renderer, allowing to add a custom anchor element inside every heading block with a matching `a-id` ID and an `anchor` class for further CSS customization
func NewRenderer ¶
NewRenderer returns a new renderer with all the options applied
func (*Renderer) RenderFooter ¶
RenderFooter satisfies the Renderer interface
func (*Renderer) RenderHeader ¶
RenderHeader satisfies the Renderer interface
func (*Renderer) RenderNode ¶
RenderNode satisfies the Renderer interface