百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

gomark

> 编程语言
开源

gomark 这是一个快速、可扩展且结构清晰的 Markdown 解析器,针对简单性和性能进行了优化。特点 - 快速、轻量级、高性能 - 可扩展 - 可配置 - 可定制 - 可测试 - 可移植 - 可部署 - 可持续 - 可维护 - 可重用 - 可复用 - 可扩展 - 可定制 - 可测试 - 可移植 - 可部署 - 可持续 - 可维护 - 可重用 - 可复用 - 可扩展 - 可定制 - 可测试 - 可移植 - 可部署 - 可持续 - 可维护 - 可重用 - 可复用 - 可扩展 - 可定制 - 可测试 - 可移植 - 可部署 - 可持续 - 可维护 - 可重用 - 可复

100 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

gomark 这是一个快速、可扩展且结构清晰的 Markdown 解析器,针对简单性和性能进行了优化。特点 - 快速、轻量级、高性能 - 可扩展 - 可配置 - 可定制 - 可测试 - 可移植 - 可部署 - 可持续 - 可维护 - 可重用 - 可复用 - 可扩展 - 可定制 - 可测试 - 可移植 - 可部署 - 可持续 - 可维护 - 可重用 - 可复用 - 可扩展 - 可定制 - 可测试 - 可移植 - 可部署 - 可持续 - 可维护 - 可重用 - 可复用 - 可扩展 - 可定制 - 可测试 - 可移植 - 可部署 - 可持续 - 可维护 - 可重用 - 可复

gomark

A fast, extensible, and well-structured markdown parser for Go, optimized for simplicity and performance.

Features

  • Fast & Lightweight: Simple token-based parsing with excellent performance
  • Extensible: Modular architecture with configurable extensions
  • Standards Compliant: Supports CommonMark with useful extensions
  • Roundtrip Support: Parse → modify → restore back to markdown
  • ️ Type Safe: Clean Go interfaces with comprehensive error handling
  • Well Tested: Comprehensive test suite with high coverage

Supported Markdown Features

Core Markdown

  • Text formatting: Bold, italic, bold-italic, strikethrough
  • Code: Inline code and fenced code blocks
  • Links & Images: Manual links, auto-links, and images
  • Lists: Ordered, unordered, and task lists
  • Structure: Headings, paragraphs, blockquotes, horizontal rules

Extensions

  • Tables: GitHub-flavored table syntax
  • Math: Inline ($math$) and block ($$math$$) expressions
  • Highlighting: ==highlighted text==
  • Subscript/Superscript: ~sub~ and ^super^
  • Spoilers: ||spoiler text||
  • Tags: #hashtag syntax
  • Referenced Content: [[wiki-style]] links
  • Embedded Content: ![[embeds]]
  • HTML Elements: , ` `, , , , and more

Quick Start

gomark is designed for zero-configuration usage - all features are enabled by default:

…

Advanced Usage

Custom Configuration

While gomark works great with zero configuration, you can customize it if needed:

go
import (
    "github.com/usememos/gomark"
    "github.com/usememos/gomark/config"
)

// Customize limits if needed
engine := gomark.NewEngine(gomark.WithConfig(
    config.DefaultConfig().WithMaxDepth(100).WithMaxFileSize(1024 * 1024), // 1MB limit
))

doc, err := engine.Parse(markdown)

Multiple Output Formats

go
import (
    "github.com/usememos/gomark/renderer"
    "github.com/usememos/gomark/renderer/html"
    "github.com/usememos/gomark/renderer/string"
)

// Parse once, render to multiple formats
doc, _ := gomark.Parse(markdown)

// Render to HTML
htmlRenderer := html.NewHTMLRenderer()
htmlOutput := htmlRenderer.RenderDocument(doc)

// Extract plain text
stringRenderer := string.NewStringRenderer()
textOutput := stringRenderer.RenderDocument(doc)

// Render back to markdown (roundtrip)
markdownOutput := gomark.Restore(doc)

Available Configurations

go
import "github.com/usememos/gomark/config"

// Default configuration: all features enabled with generous limits
cfg := config.DefaultConfig()

// Custom limits if needed
cfg := config.DefaultConfig().
    WithMaxDepth(50).                   // Limit nesting depth
    WithMaxFileSize(1024 * 1024)        // 1MB file size limit

Architecture

gomark follows a clean, modular architecture:

gomark/
├── ast/              # Abstract Syntax Tree definitions
├── config/           # Configuration management
├── parser/           # Parsing logic and tokenization
│   ├── internal/     # Parser implementations
│   ├── tokenizer/    # Tokenization engine
│   └── tests/        # Comprehensive parser tests
├── renderer/         # Output rendering
│   ├── html/         # HTML renderer
│   ├── markdown/     # Markdown renderer (roundtrip)
│   └── string/       # Plain text renderer
└── gomark.go         # Main engine and public API

Design Principles

  1. Simplicity over Complexity: Clean, understandable code
  2. Performance over Features: Fast parsing with minimal overhead
  3. Extensibility: Easy to add new features without breaking existing code
  4. Type Safety: Proper Go interfaces and error handling
  5. Testing: Comprehensive test coverage for reliability

Performance

gomark is designed for performance:

  • Token-based parsing: Efficient single-pass tokenization
  • Minimal allocations: Reuses buffers and objects where possible
  • Simple AST: Direct field access instead of complex tree operations
  • Focused scope: Implements what's needed, not theoretical features

Extensions

All extensions can be configured via the config package:

go
cfg := config.DefaultConfig()

// Disable specific extensions
cfg = cfg.WithExtension("tables", false)
cfg = cfg.WithExtension("math", false)

// Enable strict parsing
cfg = cfg.WithStrictMode(true)

// Enable safe mode (sanitizes content)
cfg = cfg.WithSafeMode(true)

Available Extensions

Extension Default Description
tables ✅ GitHub-flavored table syntax
strikethrough ✅ ~~strikethrough~~ text
autolinks ✅ Automatic URL detection
tasklists ✅ - [ ] and - [x] checkboxes
math ✅ $inline$ and $$block$$ math
highlighting ✅ ==highlighted== text
subscript ✅ ~subscript~ text
superscript ✅ ^superscript^ text
spoilers ✅ ||spoiler|| text
embedded ✅ ![[embedded]] content
references ✅ [[referenced]] content
tags ✅ #hashtag syntax

Recent Improvements

  • ✅ Phase 1 HTML Elements: Added support for , ` `, , ,
  • ✅ Simplified Configuration: Zero-config usage with sensible defaults
  • ✅ Enhanced HTML Parsing: Proper attribute handling and self-closing tag support
  • ✅ Fixed blockquote blank lines (GitHub issue #19)
  • ✅ Refactored to modular architecture
  • ✅ Improved package organization with public APIs
  • ✅ Enhanced test coverage with 26+ HTML element test cases

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass: go test ./...
  5. Submit a pull request

License

This project is part of the Memos ecosystem.

Inspiration

Designed for simplicity, performance, and ease of use. gomark focuses on practical markdown parsing with clean, maintainable code.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gogomarkdownparser

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言