Migrates goldmark extensions from v1 to v2, covering breaking changes, new extension patterns, and parser/renderer option splitting.
Ships in migrate-goldmark-v1-to-v2. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill helps you migrate a goldmark (https://github.com/yuin/goldmark) extension from version 1 to version 2. It provides guidance on the changes needed to update your project to be compatible with the new version of goldmark.
type Option interface {
myOption()
}
type ParserOption interface {
Option
applyParserOption(*parserConfig)
}
type RendererOption interface {
Option
applyRendererOption(*rendererConfig)
}
func New(opts ...Option) goldmark.Extender { // takes unified options
// ...
}
type ParserOption interface {
applyParserOption(*parserConfig)
}
type HTMLRendererOption interface { // explicitly named for **HTML**
applyRendererOption(*htmlRendererConfig) // you can access the shared renderer config like `XHTML` or `Unsafe` in the renderer config
}
func NewParser(opts ...ParserOption) parser.Extension { // takes parser options
// ...
}
func NewHTMLRenderer(opts ...HTMLRendererOption) html.Extension { // takes renderer options
// ...
}
Accessing global configuration from an extension
If a parser or renderer extension needs to refer to global configuration, always keep a reference to the Config. Do not copy its properties.
func (e *myHTMLRendererExtension) RendererOptions(config *html.Config) []html.Option {
e.formatConfig = config // OK
// e.isInTightBlockFunc = config.Paragraph.IsInTightBlockFunc // NG
return []html.Option{
html.WithNodeRenderers(map[ast.NodeKind]html.NodeRenderer{
KindMyNode: html.NodeRendererFunc(e.renderMyNode),
}),
}
}
config can be modified by other extensions. If a later extension updates config through the html.Option it returns, a copied property will remain stale.
text.Value(single line), text.MultiLineValue(multi-line) instead of []byte for values that can be parsed from source text in inline AST nodes.
text.Decoder implementation to decode the source value
text.IdentityDecoder : for raw contents like inline HTMLs, inline code, etc.reader.Decoder : other contents like text, links, etc. This decoder decodes entity references, \ escapes, etc.text.Decoder. DO NOT use text.IdentityDecoder unless you have a clear intention to do so.text.Lines instead of []text.Segment for values in block AST nodes that have raw contents like HTML blocks, code blocks, etc.text.Value as possible.
// Dump implements Node.Dump.
func (n *Text) Dump(_ []byte) *NodeDump {
m := map[string]any{
"Value": n.Value, // text.Value
}
fs := textFlagsString(n.flags)
if len(fs) != 0 {
m["Flags"] = fs
}
return NewNodeDump(n, m)
}
// Dump implements Node.Dump.
func (n *Text) Dump(source []byte) *NodeDump {
m := map[string]any{
"Value": n.Value.Str(source), // string
}
fs := textFlagsString(n.flags)
if len(fs) != 0 {
m["Flags"] = fs
}
return NewNodeDump(n, m)
}
text.Value which has almost the same specification as HTML attributes.
goldmark_v1_attribute build tag to continue using v1 attributes as they are.SetPos appropriately.text.Value and text.Lines can be rendered using the WriteTo method whenever possible. Also, the output destination of WriteTo should use html.ContextHTMLWriter(rc) or html.ContextTextWriter(rc).
tw := html.ContextTextWriter(rc)
_, _ = n.Value.WriteTo(tw, source)
WriteTo is fast because it does not allocate new memory. On the other hand, if you write Value directly like tw.Write(n.Value.Value(source)), it may copy the contents of Value, which can degrade performance.myext.NewParser() and myext.NewHTMLRenderer() for the extension constructors.
meta extension
meta.NewParser(), meta.NewHTMLRenderer()var Parser = NewParser(). Extensions MUST NOT be shared among multiple parsers/renderers because ParserOptions/RendererOptions may initialize per-parser/renderer state. Users must create them with the constructors.myext.ParserOption and myext.HTMLRendererOption for functional options.
type ParseOption func(*parserConfig), type HTMLRendererOption func(*htmlRendererConfig)main or master. User must create a new branch like 'v2' to work on the migration before using this skill.
main or master, STOP this skill and ask human to create a new branch like 'v2' to work on the migration.go.mod file is updated to use github.com/yuin/goldmark/v2 instead of github.com/yuin/goldmark. User must add goldmark/v2 before using this skill.
go.mod file is not updated, STOP this skill and ask human to update go.mod file to use github.com/yuin/goldmark/v2 instead of github.com/yuin/goldmark.go.mod file with new major version. For example, change github.com/you/yourextension to github.com/you/yourextension/v2.
go.mod file before proceeding with the migration.
go.mod file with new major version.What SKILL.md sets; muted values are Claude Code's defaults
/migrate-goldmark-v1-to-v2:migrate-goldmark-extension-v1-to-v2from migrate-goldmark-v1-to-v2
npx claudepluginhub yuin/goldmark --plugin migrate-goldmark-v1-to-v22 skills in this plugin
Other plugins' skills for the same job