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

mark

> 编程语言
开源

一个写在Go.的标记下处理器,是为好玩而建造的.

200 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个写在Go.的标记下处理器,是为好玩而建造的.

Archived. use https://github.com/russross/blackfriday instead

Mark Test coverage Build status Go doc

A markdown processor written in Go. built for fun.

Mark is a markdown processor that supports all the features of GFM, smartypants and smart-fractions rendering.
It was built with a nice-ish concurrency model that fully inspired from Rob Pike - Lexical Scanning talk and marked project.
Please note that any contribution is welcomed and appreciated, so feel free to take some task here.

Table of contents:

  • Get Started
  • Examples
  • Documentation
    • Render
    • type Mark
      • New
      • AddRenderFn
      • Render
    • smartypants and smartfractions
  • Todo

Get Started

Installation

bash
$ go get github.com/a8m/mark

Examples

Add to your project:

go
import (
	"fmt"
	"github.com/a8m/mark"
)

func main() {
	html := mark.Render("I am using __markdown__.")
	fmt.Println(html)
	// 
I am using markdown.

}

or using as a command line tool:

1. install:

bash
$ go get github.com/a8m/mark/cmd/mark

2. usage:

bash
$ echo 'hello __world__...' | mark -smartypants

or:

bash
$ mark -i hello.text -o hello.html

Documentation

Render

Staic rendering function.

go
html := mark.Render("I am using __markdown__.")
fmt.Println(html)
// 
I am using markdown.
Mark
New

New get string as an input, and mark.Options as configuration and return a new Mark.

go
m := mark.New("hello world...", &mark.Options{
    Smartypants: true,
})
fmt.Println(m.Render())
// 
hello world…

// Note: you can instantiate it like so: mark.New("...", nil) to get the default options.
Mark.AddRenderFn

AddRenderFn let you pass NodeType, and RenderFn function and override the default Node rendering.
To get all Nodes type and their fields/methods, see the full documentation: go-doc

Example 1:

go
m := mark.New("hello", nil)
m.AddRenderFn(mark.NodeParagraph, func(node mark.Node) (s string) {
    p, _ := node.(*mark.ParagraphNode)
    s += "
"
    for _, n := range p.Nodes {
        s += n.Render()
    }
    s += "
"
    return
})
fmt.Println(m.Render())
// 
hello

Example 2:

go
m := mark.New("# Hello world", &mark.Options{
	Smartypants: true,
	Fractions:   true,
})
m.AddRenderFn(mark.NodeHeading, func(node mark.Node) string {
	h, _ := node.(*mark.HeadingNode)
	return fmt.Sprintf("", h.Level, h.Text)
})
fmt.Println(m.Render())
// 
Mark.Render

Parse and render input.

go
m := mark.New("hello", nil)
fmt.Println(m.Render())
// 
hello

Smartypants and Smartfractions

Mark also support smartypants and smartfractions rendering

go
func main() {
	opts := mark.DefaultOptions()
	opts.Smartypants = true
	opts.Fractions = true
	m := mark.New("'hello', 1/2 beer please...", opts)
	fmt.Println(m.Render())
	// ‘hello’, ½ beer please…
}

Todo

  • Commonmark support v0.2
  • Expand documentation
  • Configuration options
    • gfm, table
    • heading(auto hashing)

License

MIT

Issues· 3 开放

查看全部 Issues在 GitHub 打开

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

> 标签

Gogomarkdownmarkdown-processorprocessor

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

> 工具信息

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

> 相关工具

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