https://github.com/zombiezen/go-commonmark
CommonMark package for Go
https://github.com/zombiezen/go-commonmark
commonmark go golang golang-package markdown
Last synced: 10 months ago
JSON representation
CommonMark package for Go
- Host: GitHub
- URL: https://github.com/zombiezen/go-commonmark
- Owner: zombiezen
- License: apache-2.0
- Created: 2023-03-23T22:28:30.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-21T23:17:26.000Z (almost 2 years ago)
- Last Synced: 2024-05-01T19:44:50.028Z (over 1 year ago)
- Topics: commonmark, go, golang, golang-package, markdown
- Language: Go
- Homepage: https://pkg.go.dev/zombiezen.com/go/commonmark
- Size: 397 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# `zombiezen.com/go/commonmark`
[][reference docs]
This Go package provides a [CommonMark][] parser,
a specific dialect of [Markdown][].
It allows you to parse, analyze, and render CommonMark/Markdown documents
with an [abstract syntax tree][] API.
This implementation conforms to [Version 0.30 of the CommonMark Specification][].
[abstract syntax tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
[CommonMark]: https://commonmark.org/
[Markdown]: https://daringfireball.net/projects/markdown/
[reference docs]: https://pkg.go.dev/zombiezen.com/go/commonmark
[Version 0.30 of the CommonMark Specification]: https://spec.commonmark.org/0.30/
## Goals
A few other Markdown/CommonMark packages exist for Go.
This package prioritizes (in order):
1. Ability to connect the parse tree to CommonMark input losslessly
in order to enable creation of tools that reformat or manipulate CommonMark documents.
2. Adherence to CommonMark specification.
3. Comprehensibility of implementation.
4. Performance.
## Install
```shell
go get zombiezen.com/go/commonmark
```
## Getting Started
```go
package main
import (
"fmt"
"io"
"os"
"zombiezen.com/go/commonmark"
)
func main() {
commonmarkSource, err := io.ReadAll(os.Stdin)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
blocks, refMap := commonmark.Parse(commonmarkSource)
commonmark.RenderHTML(os.Stdout, blocks, refMap)
}
```
## License
[Apache 2.0](LICENSE)