goldmark

The Golden Swiss Army Knife for markdown processing. 100% CommonMark compliant, AST w/ CST, Extensible, Fast, CJK-friendly.
goldmark is compliant with CommonMark 0.31.2.
There is also a Rust version of goldmark: rushdown
v2 status
v2 is still in the early stages of release. If you are using an extension that does not support v2, please use v1.
v2 Motivation
goldmark was originally created with a focus on my personal goals.
- Extensible. You can easily add your own syntax to Markdown.
- Performance. Prioritize performance over semantically perfect AST.
- Focus on the purpose of converting to HTML.
Unexpectedly, goldmark has been used by many people.
goldmark has become a major Markdown parser in Go ecosystem.
In such a situation, there have been many requests regarding use cases that were not emphasized at the time of initial creation.
- Semantic analysis of Markdown documents using AST
- Use cases that use more detailed position information, such as LSP servers
In particular, as Markdown documents have come to be used as Lingua franca for AI, there is an increasing need to analyze Markdown documents semantically. For the same reason, there are also increasing use cases for generating Markdown documents rather than parsing them. The use of CLI in AI agents is increasing, also a growing need to convert to formats other than HTML.
Breaking changes to an extensible library like goldmark have a huge impact, as third-party extensions will no longer work. Therefore, I have avoided making breaking changes for a long time.
It has been more than 7 years since goldmark was created, and technical debt has been accumulating. In the meantime, the Go language specification has changed significantly, including the introduction of generics. I believe that the changes in use cases, represented by AI, are a good opportunity to fundamentally review the design of goldmark, and I have decided to make breaking changes.
v2 and v1 differences
- v2 focuses on building a more semantic AST.
- v2 uses generics.
- v2 clearly separates the parser and renderer. This makes it easier to implement rendering to formats other than HTML.
- v2 allows you to programmatically build an AST. And you can render the constructed AST to another format.
- v2 all nodes hold the start position. In the future, third-party extensions that support v2 are also expected to hold the start position.
- The core parsing algorithm is the same as v1. Third-party extensions must support v2, but the most complex parsing part can be used almost as it is.
Maintenance policy
This project will maintain bug fixes, including security fixes, up to one major version prior to the latest major version.
Migrating from v1 to v2
You can use LLMs to migrate your code from v1 to v2.
Claude Code / Copilot CLI
/plugin marketplace add yuin/goldmark@v2
/plugin install migrate-goldmark-v1-to-v2@yuin-goldmark-v2
Migrating your goldmark extension projects:
/migrate-goldmark-v1-to-v2:migrate-goldmark-extension-v1-to-v2
Migrating your applications using goldmark:
/migrate-goldmark-v1-to-v2:migrate-goldmark-app-v1-to-v2
These skills will create a migration plan for your project and execute the migration plan to update your code to be compatible with goldmark v2.
Of course, even you can migrate manually if they understand these contents :)
See .agent-plugins directory for the implementation of these skills.
Features