All Projects → a8m → Mark

a8m / Mark

Licence: mit
A markdown processor written in Go. built for fun.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Mark

Cgx
💻🔥CLI to generate the recommended documentation/files to improve contribution (Github, Gitlab, CodeCommit and Bitbucket)
Stars: ✭ 190 (-5%)
Mutual labels:  markdown
Awesome
A curated list of awesome MDX resources
Stars: ✭ 195 (-2.5%)
Mutual labels:  markdown
Evernote2md
Convert Evernote .enex files to Markdown
Stars: ✭ 193 (-3.5%)
Mutual labels:  markdown
Cattaz
Realtime collaborative tool which can run custom applications in a Wiki page
Stars: ✭ 191 (-4.5%)
Mutual labels:  markdown
Pdfcpu
A PDF processor written in Go.
Stars: ✭ 2,852 (+1326%)
Mutual labels:  processor
Markdown Pdf
📄 Markdown to PDF converter
Stars: ✭ 2,365 (+1082.5%)
Mutual labels:  markdown
Alfred Mweb Workflow
搜索、打开MWeb 内部文档和外部 Markdown 文档
Stars: ✭ 188 (-6%)
Mutual labels:  markdown
Bullets.vim
🔫 Bullets.vim is a Vim/NeoVim plugin for automated bullet lists.
Stars: ✭ 199 (-0.5%)
Mutual labels:  markdown
Markdown
Learn how to use Markdown
Stars: ✭ 193 (-3.5%)
Mutual labels:  markdown
Database
EhTagTranslation 项目的翻译数据。
Stars: ✭ 197 (-1.5%)
Mutual labels:  markdown
Pandoc Markdown Book Template
A template for creating epub books from markdown using pandoc.
Stars: ✭ 191 (-4.5%)
Mutual labels:  markdown
Docdown
A simple JSDoc to Markdown generator.
Stars: ✭ 191 (-4.5%)
Mutual labels:  markdown
Qimage Win
Windows 版本 Markdown 一键贴图工具,支持本地文件、截图、网络图片一键上传七牛云并返回图片引用,让 Markdown 中贴图变成一种享受。
Stars: ✭ 196 (-2%)
Mutual labels:  markdown
Hacktoberfest
Make your first PR! ~ A beginner-friendly repository made specifically for open source beginners. Add your profile, a blog or any program under any language (it can be anything from a hello-world program to a complex data structure algorithm) or update the existing one. Just make sure to add the file under the correct directory. Happy hacking!
Stars: ✭ 191 (-4.5%)
Mutual labels:  markdown
Tslide
Terminal SlideDeck, supporting markdown.
Stars: ✭ 198 (-1%)
Mutual labels:  markdown
Abricotine
Markdown editor with inline preview
Stars: ✭ 2,308 (+1054%)
Mutual labels:  markdown
Diagon
Interactive ASCII art diagram generators. 🌟
Stars: ✭ 189 (-5.5%)
Mutual labels:  markdown
Markdown Link Check
checks that all of the hyperlinks in a markdown text to determine if they are alive or dead
Stars: ✭ 198 (-1%)
Mutual labels:  markdown
Swagger2markup
A Swagger to AsciiDoc or Markdown converter to simplify the generation of an up-to-date RESTful API documentation by combining documentation that’s been hand-written with auto-generated API documentation.
Stars: ✭ 2,330 (+1065%)
Mutual labels:  markdown
Hercule
♻️ Simple document transclusion, ideal for Markdown documents
Stars: ✭ 196 (-2%)
Mutual labels:  markdown

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

Mark Test coverage Build status Go doc license

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

Installation

$ go get github.com/a8m/mark

Examples

Add to your project:

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

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

or using as a command line tool:

1. install:

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

2. usage:

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

or:

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

Documentation

Render

Staic rendering function.

html := mark.Render("I am using __markdown__.")
fmt.Println(html)
// <p>I am using <strong>markdown</strong>.</p>
Mark
New

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

m := mark.New("hello world...", &mark.Options{
    Smartypants: true,
})
fmt.Println(m.Render())
// <p>hello world…</p>
// 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:

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

Example 2:

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("<angular-heading-directive level=\"%d\" text=\"%s\"/>", h.Level, h.Text)
})
fmt.Println(m.Render())
// <angular-heading-directive level="1" text="Hello world"/>
Mark.Render

Parse and render input.

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

Smartypants and Smartfractions

Mark also support smartypants and smartfractions rendering

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].