mark

所属分类:代码编辑器
开发工具:GO
文件大小:44KB
下载次数:0
上传日期:2019-09-09 10:56:48
上 传 者sh-1993
说明:  用Go编写的降价处理器。专为娱乐打造。
(A markdown processor written in Go. built for fun.)

文件列表:
.travis.yml (277, 2019-09-09)
LICENSE (1074, 2019-09-09)
cmd (0, 2019-09-09)
cmd\mark (0, 2019-09-09)
cmd\mark\main.go (2076, 2019-09-09)
grammar.go (3410, 2019-09-09)
lexer.go (13225, 2019-09-09)
lexer_test.go (7329, 2019-09-09)
mark.go (1194, 2019-09-09)
mark_test.go (31789, 2019-09-09)
node.go (14642, 2019-09-09)
parser.go (10111, 2019-09-09)
parser_test.go (1993, 2019-09-09)
test (0, 2019-09-09)
test\auto_links.html (182, 2019-09-09)
test\auto_links.text (79, 2019-09-09)
test\backslash_escapes.html (648, 2019-09-09)
test\backslash_escapes.text (538, 2019-09-09)
test\blockquote_list_item.html (182, 2019-09-09)
test\blockquote_list_item.text (70, 2019-09-09)
test\blockquotes_code_blocks.html (168, 2019-09-09)
test\blockquotes_code_blocks.text (125, 2019-09-09)
test\blockquotes_def.html (79, 2019-09-09)
test\blockquotes_def.text (26, 2019-09-09)
test\blockquotes_nested.html (86, 2019-09-09)
test\blockquotes_nested.text (23, 2019-09-09)
test\blockquotes_text.html (252, 2019-09-09)
test\blockquotes_text.text (121, 2019-09-09)
test\code_blocks.html (311, 2019-09-09)
test\code_blocks.text (200, 2019-09-09)
test\code_spans.html (86, 2019-09-09)
test\code_spans.text (51, 2019-09-09)
test\emphasis.html (353, 2019-09-09)
test\emphasis.text (160, 2019-09-09)
test\gfm_code_blocks.html (107, 2019-09-09)
test\gfm_code_blocks.text (47, 2019-09-09)
test\gfm_del.html (63, 2019-09-09)
... ...

Archived. use https://github.com/russross/blackfriday instead # Mark [![Test coverage][coveralls-image]][coveralls-url] [![Build status][travis-image]][travis-url] [![Go doc][doc-image]][doc-url] [![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/a8m/mark/master/LICENSE) > A [markdown](http://daringfireball.net/projects/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](https://www.youtube.com/watch?v=HxaD_trXwRE) and [marked](https://github.com/chjj/marked) project. Please note that any contribution is welcomed and appreciated, so feel free to take some task [here](#todo). ## Table of contents: - [Get Started](#get-started) - [Examples](#examples) - [Documentation](#documentation) - [Render](#render) - [type Mark](#mark) - [New](#new) - [AddRenderFn](#markaddrenderfn) - [Render](#markrender) - [smartypants and smartfractions](##smartypants-and-smartfractions) - [Todo](#todo) ### Get Started #### Installation ```sh $ 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: ```sh $ go get github.com/a8m/mark/cmd/mark ``` 2\. usage: ```sh $ echo 'hello __world__...' | mark -smartypants ``` or: ```sh $ 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](http://godoc.org/github.com/a8m/mark) 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](http://daringfireball.net/projects/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’, 12 beer please... } ``` ### Todo - Commonmark support v0.2 - Expand documentation - Configuration options - gfm, table - heading(auto hashing) ### License MIT [travis-url]: https://travis-ci.org/a8m/mark [travis-image]: https://api.travis-ci.org/a8m/mark.svg [coveralls-image]: https://coveralls.io/repos/a8m/mark/badge.svg?branch=master&service=github [coveralls-url]: https://coveralls.io/r/a8m/mark [doc-image]: https://godoc.org/github.com/a8m/mark?status.svg [doc-url]: https://godoc.org/github.com/a8m/mark

近期下载者

相关文件


收藏者