跳到正文
Skillpedia
API 与服务器(后端)5.1k · #15050

migrate-goldmark-app-v1-to-v2

它能做什么

它为 goldmark v2 规划并执行所需的改动,先由你批准计划,最后进行测试。适合在应用中使用 goldmark 的 Go 开发者。

适用场景

  • ✓当你的 Go 应用使用 goldmark v1,并想迁移到 v2 时。
  • ✓当你需要了解 goldmark v1 与 v2 之间的不兼容变化时。
  • ✓当你希望在开始修改代码之前先确认迁移计划时。

技能链接

https://github.com/yuin/goldmark/blob/v2/.agent-plugins/migrate-goldmark-v1-to-v2/skills/migrate-goldmark-app-v1-to-v2/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/yuin/goldmark/blob/v2/.agent-plugins/migrate-goldmark-v1-to-v2/skills/migrate-goldmark-app-v1-to-v2/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我把 Go 应用从 goldmark v1 迁移到 v2,并在修改任何代码之前与我确认计划。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会先写出迁移计划供你确认,然后更新代码、调整测试,并针对 goldmark v2 运行测试。它会参考关于不兼容变化的说明文档。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

migrate-goldmark-app-v1-to-v2

Description

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.

Knowledges

  • CommonMark key points : List of key points of CommonMark spec that you should be aware of when implementing a goldmark extension.
  • Breaking changes in v2 : List of breaking changes in goldmark v2 that you should be aware of when migrating your extension from v1 to v2.

Migration steps

Overview of the migration process

  • Create a migration plan for the application.
  • MUST ask human to confirm that the migration plan is acceptable before proceeding with the migration.
  • MUST ask human to how to test the application after migration before proceeding with the migration.
    • e.g. : "How do you want to test the application after migration? Do you have any test cases or examples that you want to use for testing?"
  • Execute the migration plan to update the application code to be compatible with goldmark v2.
  • Update the test cases to ensure that the application works as expected with goldmark v2.
  • Test the application with goldmark v2 to ensure that it works as expected. If there are any issues, fix them and re-test until the application works as expected.
  • Update the documentation to reflect any changes made during the migration process.

Create a migration plan

Task

  • Make sure you have read and understood the Breaking changes in v2 document.
  • Make sure you have read and understood the How to create an extension document.
  • You create a ./features/goldmark-migration-plan.md file that contains a migration plan for the extension.

Extension

  • If the application contains own extensions, you can use /migrate-goldmark-extension-v1-to-v2 skill to migrate the extensions.
  • If the application contains third-party extensions, you need to check if the extensions provide v2 compatible version. - If not, STOP the migration.

Key points to consider when migrating your application

goldmark.Markdown alternatives
  • In v2, goldmark.Markdown is removed. Therefore, you need to replace it with one of the following two patterns:
    • Pattern 1: Use parser.Parser and renderer.Renderer to create your own goldmark.Markdown alternative.
      • Example:
        // MarkdownToStringFunc is a function type that converts markdown to HTML.
        type MarkdownToStringFunc func(source string) (string, error)
        
        // NewMarkdownToStringFunc returns a MarkdownToStringFunc that uses the given parser and renderer.
        func NewMarkdownToStringFunc(p parser.Parser, r html.Renderer) MarkdownToStringFunc {
            return func(source string) (string, error) {
                var buf bytes.Buffer
                b := util.StringToReadOnlyBytes(source)
                doc := p.Parse(b)
                if err := r.Render(&buf, b, doc); err != nil {
                    return "", err
                }
                return buf.String(), nil
            }
        }
        
    • Pattern 2: Use parser.Parser and renderer.Renderer separately.
      • Example:
        var buf bytes.Buffer
        p := parser.New(parser.WithAttribute(), parser.WithExtensions(extension.NewStrikethroughParser()))
        r := html.New(html.WithXHTML(), html.WithUnsafe(), html.WithExtensions(extension.NewStrikethroughHTMLRenderer()))
        doc := p.Parse(b)
        err := r.Render(&buf, b, doc)
        
  • Extensions MUST NOT be shared among multiple parsers/renderers. Create them with the New* constructors (e.g. extension.NewTableParser()) for each parser/renderer instead of using the deprecated default instances (e.g. extension.TableParser).
AST
  • In v1, AST values are mostly 'raw' values; entities references and \ escapes are not resolved. In v2, AST values are resolved values.
    • You need to check if your application relies on the 'raw' values of AST nodes.
      • If your application relies on the resolved values of AST nodes, you should replace Value.Bytes and Value.Str methods with Value.Value method.
      • Otherwise, you should replace Value.Bytes and Value.Str methods with Value.Value method.
  • In v2, to make the AST more semantic, some breaking changes have occurred.
常见问题

智能体会马上开始改代码吗?

不会。该技能要求你先确认迁移计划,并说明如何测试。

什么帮助它了解 v2 的变化?

关于 v2 不兼容变化的参考文档,以及 CommonMark 的要点。

扩展的迁移有单独的技能吗?

有。goldmark 扩展的迁移有自己的技能。

详情

作者的原始描述

Migrate your application from goldmark v1 to v2.

repo: yuin/goldmark

热度

GitHub 星标
5.1k
排名
#15050
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能