Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.
/ go-commonmark Public archive

[FORK] The CommonMark-compliant markdown parser and renderer in Go.

License

Notifications You must be signed in to change notification settings

skyzyx/go-commonmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown GoDoc License Pipeline status Coverage report

Package golang-commonmark/markdown provides a CommonMark-compliant markdown parser and renderer, written in Go.

Installation

go get -u gitlab.com/golang-commonmark/markdown

You can also go get mdtool, an example command-line tool:

go get -u gitlab.com/golang-commonmark/mdtool

Standards support

Currently supported CommonMark spec: v0.28.

Extensions

Besides the features required by CommonMark, golang-commonmark/markdown supports:

  • Tables (GFM)
  • Strikethrough (GFM)
  • Autoconverting plain-text URLs to links
  • Typographic replacements (smart quotes and other)

Usage

md := markdown.New(markdown.XHTMLOutput(true))
fmt.Println(md.RenderToString([]byte("Header\n===\nText")))

Check out the source of mdtool for a more complete example.

The following options are currently supported:

Name Type Description Default
HTML bool whether to enable raw HTML false
Tables bool whether to enable GFM tables true
Linkify bool whether to autoconvert plain-text URLs to links true
Typographer bool whether to enable typographic replacements true
Quotes string / []string double + single quote replacement pairs for the typographer “”‘’
MaxNesting int maximum nesting level 20
LangPrefix string CSS language prefix for fenced blocks language-
Breaks bool whether to convert newlines inside paragraphs into <br> false
XHTMLOutput bool whether to output XHTML instead of HTML false

Benchmarks

Rendering spec/spec-0.28.txt on a Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz

BenchmarkRenderSpecNoHTML         100    10254720 ns/op    2998037 B/op    18225 allocs/op
BenchmarkRenderSpec               100    10180241 ns/op    2997307 B/op    18214 allocs/op
BenchmarkRenderSpecBlackFriday    200     7241749 ns/op    2834340 B/op    17101 allocs/op
BenchmarkRenderSpecBlackFriday2   200     7448256 ns/op    2991202 B/op    16705 allocs/op

See also

https://github.com/jgm/CommonMark — the reference CommonMark implementations in C and JavaScript, also contains the latest spec and an online demo.

http://talk.commonmark.org — the CommonMark forum, a good place to join together the efforts of the developers.

About

[FORK] The CommonMark-compliant markdown parser and renderer in Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages