Skip to content

GoMarkdown is a Go library for generating Markdown documents programmatically.

License

Notifications You must be signed in to change notification settings

Bistutu/GoMarkdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoMarkdown

中文

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.

Features

  • 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

Installation

To install GoMarkdown, use the following go get command:

go get github.com/Bistutu/GoMarkdown@latest

Usage

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...
}

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/YourFeature).
  3. Make your changes and commit them (git commit -m 'Add YourFeature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a new Pull Request.

Please adhere to the Go style guidelines when contributing.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

  • Go - The Go programming language
  • Markdown Guide - A comprehensive guide to Markdown syntax

About

GoMarkdown is a Go library for generating Markdown documents programmatically.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages