GoMarkdown is a Go library for generating Markdown documents programmatically. It offers comprehensive support for various Markdown elements, from basic formatting to advanced features like Mermaid diagrams, mathematical expressions, and GitHub-style alert boxes.
-
Basic Markdown Elements:
- Headings (H1-H6)
- Bold, Italic, Strikethrough text
- Inline code and code blocks
- Horizontal rules
- Links and Images (with customizable size and scale)
- Blockquotes and Footnotes
- Unordered and ordered lists, task lists
- Definition lists and Table of contents
-
Advanced Features:
- Mermaid diagrams (sequence diagrams, flowcharts, and custom diagrams)
- Mathematical expressions using LaTeX syntax (inline and block)
- GitHub-style alert boxes (note, warning, danger)
- Custom HTML content embedding
To install GoMarkdown, use the following go get
command:
go get github.com/Bistutu/GoMarkdown@latest
Here's an example of how to use GoMarkdown to create a Markdown document:
package main
import (
"fmt"
"os"
"github.com/Bistutu/GoMarkdown"
)
func main() {
// Create a MarkdownWriter instance
writer, err := gomarkdown.NewMarkdownWriter("example.md", true)
if err != nil {
fmt.Printf("Failed to create MarkdownWriter: %v\n", err)
return
}
defer writer.Close()
// Generate Markdown content
writer.H1("GoMarkdown Example")
writer.Bold("This is bold text")
writer.Italic("This is italic text")
writer.Code("go", `fmt.Println("Hello, GoMarkdown!")`)
writer.ImageWithScale("Sample Image", "https://example.com/image.png", 50)
// Additional Markdown generation examples...
}
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature
). - Make your changes and commit them (
git commit -m 'Add YourFeature'
). - Push to the branch (
git push origin feature/YourFeature
). - Open a new Pull Request.
Please adhere to the Go style guidelines when contributing.
This project is licensed under the MIT License. See the LICENSE file for details.
- Go - The Go programming language
- Markdown Guide - A comprehensive guide to Markdown syntax