Documentation ¶
Index ¶
Constants ¶
const ( CbPrompt = template.HTML(" ►") TmplName = "tmplCodeBlock" )
Variables ¶
var ( //go:embed codeblock.js Js string //go:embed codeblock.css Css string )
Functions ¶
Types ¶
type HighlightedCbRenderer ¶
HighlightedCbRenderer is an implementation of renderer.NodeRenderer, but despite the name of the interface, instances of this interface don't actually render anything.
All an instance does is provide a method that registers a "Kind" with a rendering function. The rendering function can live anywhere, and in this case it lives in an instance of HighlightedCodeBlock.
func (*HighlightedCbRenderer) RegisterFuncs ¶
func (r *HighlightedCbRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
RegisterFuncs implements NodeRenderer.RegisterFuncs.
type HighlightedCodeBlock ¶
HighlightedCodeBlock represents a code block one might be able to run.
Sometimes we want to render a fenced code block using the normal default fenced code block rendered, e.g. when a code block is "protected" inside a blockquote. Other times we want to do a special rendering, that encourages copy/paste and execution.
In the latter case, we replace the AST node instance of a native FencedCodeBlock with an instance of HighlightedCodeBlock that has the FencedCodeBlock as its lone child in the AST. The HighlightedCodeBlock must register its own Kind and renderer with the goldmark infrastructure.
func (*HighlightedCodeBlock) Dump ¶
func (n *HighlightedCodeBlock) Dump(source []byte, level int)
Dump implements Node.Dump.
func (*HighlightedCodeBlock) Kind ¶
func (n *HighlightedCodeBlock) Kind() ast.NodeKind
Kind implements Node.Kind.