Document V2 in master README

pull/354/head
Vytautas Šaltenis 2017-05-06 19:52:33 +03:00
parent 4048872b16
commit 74be510331
1 changed files with 52 additions and 29 deletions

View File

@ -1,4 +1,6 @@
Blackfriday [![Build Status](https://travis-ci.org/russross/blackfriday.svg?branch=master)](https://travis-ci.org/russross/blackfriday) [![GoDoc](https://godoc.org/github.com/russross/blackfriday?status.svg)](https://godoc.org/github.com/russross/blackfriday) Blackfriday [![Build Status][BuildSVG]][BuildURL]
[![Godoc][GodocV1SVG]][GodocV1URL] (V1)
[![Godoc][GodocV2SVG]][GodocV2URL] (V2)
=========== ===========
Blackfriday is a [Markdown][1] processor implemented in [Go][2]. It Blackfriday is a [Markdown][1] processor implemented in [Go][2]. It
@ -8,7 +10,7 @@ punctuation substitutions, etc.), and it is safe for all utf-8
(unicode) input. (unicode) input.
HTML output is currently supported, along with Smartypants HTML output is currently supported, along with Smartypants
extensions. An experimental LaTeX output engine is also included. extensions.
It started as a translation from C of [Sundown][3]. It started as a translation from C of [Sundown][3].
@ -16,23 +18,44 @@ It started as a translation from C of [Sundown][3].
Installation Installation
------------ ------------
Blackfriday is compatible with Go 1. If you are using an older Blackfriday is compatible with any modern Go release. With Go 1.7 and git
release of Go, consider using v1.1 of blackfriday, which was based installed:
on the last stable release of Go prior to Go 1. You can find it as a
tagged commit on github.
With Go 1 and git installed: go get gopkg.in/russross/blackfriday.v2
go get github.com/russross/blackfriday
will download, compile, and install the package into your `$GOPATH` will download, compile, and install the package into your `$GOPATH`
directory hierarchy. Alternatively, you can achieve the same if you directory hierarchy. Alternatively, you can achieve the same if you
import it into a project: import it into a project:
import "github.com/russross/blackfriday" import "gopkg.in/russross/blackfriday.v2"
and `go get` without parameters. and `go get` without parameters.
Versions
--------
Currently maintained and recommended version of Blackfriday is `v2`. It's being
developed on its own branch: https://github.com/russross/blackfriday/v2. You
should install and import it via [gopkg.in][6] at
`gopkg.in/russross/blackfriday.v2`.
Version 2 offers a number of improvements over v1:
* Cleaned up API
* A separate call to [`Parse`][4], which produces an abstract syntax tree for
the document
* Latest bug fixes
* Flexibility to easily add your own rendering extensions
Potential drawbacks:
* Our benchmarks show v2 to be slightly slower than v1. Currently in the
ballpark of around 15%.
* API breakage. If you can't afford modifying your code to adhere to the new API
and don't care too much about the new features, v2 is probably not for you.
Usage Usage
----- -----
@ -49,11 +72,10 @@ feature set, use this instead:
### Sanitize untrusted content ### Sanitize untrusted content
Blackfriday itself does nothing to protect against malicious content. If you are Blackfriday itself does nothing to protect against malicious content. If you are
dealing with user-supplied markdown, we recommend running blackfriday's output dealing with user-supplied markdown, we recommend running Blackfriday's output
through HTML sanitizer such as through HTML sanitizer such as [Bluemonday][5].
[Bluemonday](https://github.com/microcosm-cc/bluemonday).
Here's an example of simple usage of blackfriday together with bluemonday: Here's an example of simple usage of Blackfriday together with Bluemonday:
``` go ``` go
import ( import (
@ -69,7 +91,7 @@ html := bluemonday.UGCPolicy().SanitizeBytes(unsafe)
### Custom options ### Custom options
If you want to customize the set of options, first get a renderer If you want to customize the set of options, first get a renderer
(currently either the HTML or LaTeX output engines), then use it to (currently only the HTML output engine), then use it to
call the more general `Markdown` function. For examples, see the call the more general `Markdown` function. For examples, see the
implementations of `MarkdownBasic` and `MarkdownCommon` in implementations of `MarkdownBasic` and `MarkdownCommon` in
`markdown.go`. `markdown.go`.
@ -249,7 +271,7 @@ are a few of note:
* [github_flavored_markdown](https://godoc.org/github.com/shurcooL/github_flavored_markdown): * [github_flavored_markdown](https://godoc.org/github.com/shurcooL/github_flavored_markdown):
provides a GitHub Flavored Markdown renderer with fenced code block provides a GitHub Flavored Markdown renderer with fenced code block
highlighting, clickable header anchor links. highlighting, clickable heading anchor links.
It's not customizable, and its goal is to produce HTML output It's not customizable, and its goal is to produce HTML output
equivalent to the [GitHub Markdown API endpoint](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode), equivalent to the [GitHub Markdown API endpoint](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode),
@ -258,17 +280,8 @@ are a few of note:
* [markdownfmt](https://github.com/shurcooL/markdownfmt): like gofmt, * [markdownfmt](https://github.com/shurcooL/markdownfmt): like gofmt,
but for markdown. but for markdown.
* LaTeX output: renders output as LaTeX. This is currently part of the * [LaTeX output](https://bitbucket.org/ambrevar/blackfriday-latex):
main Blackfriday repository, but may be split into its own project renders output as LaTeX.
in the future. If you are interested in owning and maintaining the
LaTeX output component, please be in touch.
It renders some basic documents, but is only experimental at this
point. In particular, it does not do any inline escaping, so input
that happens to look like LaTeX code will be passed through without
modification.
* [Md2Vim](https://github.com/FooSoft/md2vim): transforms markdown files into vimdoc format.
Todo Todo
@ -287,6 +300,16 @@ License
[Blackfriday is distributed under the Simplified BSD License](LICENSE.txt) [Blackfriday is distributed under the Simplified BSD License](LICENSE.txt)
[1]: http://daringfireball.net/projects/markdown/ "Markdown" [1]: https://daringfireball.net/projects/markdown/ "Markdown"
[2]: http://golang.org/ "Go Language" [2]: https://golang.org/ "Go Language"
[3]: https://github.com/vmg/sundown "Sundown" [3]: https://github.com/vmg/sundown "Sundown"
[4]: https://godoc.org/gopkg.in/russross/blackfriday.v2#Parse "Parse func"
[5]: https://github.com/microcosm-cc/bluemonday "Bluemonday"
[6]: https://labix.org/gopkg.in "gopkg.in"
[BuildSVG]: https://travis-ci.org/russross/blackfriday.svg?branch=master
[BuildURL]: https://travis-ci.org/russross/blackfriday
[GodocV1SVG]: https://godoc.org/github.com/russross/blackfriday?status.svg
[GodocV1URL]: https://godoc.org/github.com/russross/blackfriday
[GodocV2SVG]: https://godoc.org/gopkg.in/russross/blackfriday.v2?status.svg
[GodocV2URL]: https://godoc.org/gopkg.in/russross/blackfriday.v2