1
0
mirror of https://github.com/danog/blackfriday.git synced 2024-11-30 04:29:13 +01:00

Merge pull request #382 from russross/v2-final-docs-fixes

Several small documentation fixes
This commit is contained in:
Vytautas Šaltenis 2017-08-01 23:01:04 +03:00 committed by GitHub
commit e0df702112
3 changed files with 18 additions and 12 deletions

View File

@ -52,8 +52,9 @@ Potential drawbacks:
ballpark of around 15%. ballpark of around 15%.
* API breakage. If you can't afford modifying your code to adhere to the new API * 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. and don't care too much about the new features, v2 is probably not for you.
* Some bug fixes are trailing behind and still need to be forward-ported to v2. * Several bug fixes are trailing behind and still need to be forward-ported to
See issue #348 for tracking. v2. See issue [#348](https://github.com/russross/blackfriday/issues/348) for
tracking.
Usage Usage
----- -----
@ -61,13 +62,17 @@ Usage
For the most sensible markdown processing, it is as simple as getting your input For the most sensible markdown processing, it is as simple as getting your input
into a byte slice and calling: into a byte slice and calling:
output := blackfriday.Run(input) ```go
output := blackfriday.Run(input)
```
Your input will be parsed and the output rendered with a set of most popular Your input will be parsed and the output rendered with a set of most popular
extensions enabled. If you want the most basic feature set, corresponding with extensions enabled. If you want the most basic feature set, corresponding with
the bare Markdown specification, use: the bare Markdown specification, use:
output := blackfriday.Run(input, blackfriday.WithNoExtensions()) ```go
output := blackfriday.Run(input, blackfriday.WithNoExtensions())
```
### Sanitize untrusted content ### Sanitize untrusted content
@ -77,7 +82,7 @@ through HTML sanitizer such as [Bluemonday][5].
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 (
"github.com/microcosm-cc/bluemonday" "github.com/microcosm-cc/bluemonday"
"github.com/russross/blackfriday" "github.com/russross/blackfriday"
@ -179,7 +184,7 @@ implements the following extensions:
and supply a language (to make syntax highlighting simple). Just and supply a language (to make syntax highlighting simple). Just
mark it like this: mark it like this:
``` go ```go
func getTrue() bool { func getTrue() bool {
return true return true
} }

4
doc.go
View File

@ -4,8 +4,8 @@
// then be further processed to HTML (provided by Blackfriday itself) or other // then be further processed to HTML (provided by Blackfriday itself) or other
// formats (provided by the community). // formats (provided by the community).
// //
// The simplest way to invoke Blackfriday is to call the Markdown function. It // The simplest way to invoke Blackfriday is to call the Run function. It will
// will take a text input and produce a text output in HTML (or other format). // take a text input and produce a text output in HTML (or other format).
// //
// A slightly more sophisticated way to use Blackfriday is to create a Markdown // A slightly more sophisticated way to use Blackfriday is to create a Markdown
// processor and to call Parse, which returns a syntax tree for the input // processor and to call Parse, which returns a syntax tree for the input

View File

@ -19,7 +19,8 @@ import (
// Markdown parsing and processing // Markdown parsing and processing
// //
// Version string of the package. // Version string of the package. Appears in the rendered document when
// CompletePage flag is on.
const Version = "2.0" const Version = "2.0"
// Extensions is a bitwise or'ed collection of enabled Blackfriday's // Extensions is a bitwise or'ed collection of enabled Blackfriday's
@ -167,9 +168,8 @@ type Renderer interface {
// for each character that triggers a response when parsing inline data. // for each character that triggers a response when parsing inline data.
type inlineParser func(p *Markdown, data []byte, offset int) (int, *Node) type inlineParser func(p *Markdown, data []byte, offset int) (int, *Node)
// Markdown is a type that holds: // Markdown is a type that holds extensions and the runtime state used by
// - extensions and the runtime state used by Parse, // Parse, and the renderer. You can not use it directly, construct it with New.
// - the renderer.
type Markdown struct { type Markdown struct {
renderer Renderer renderer Renderer
referenceOverride ReferenceOverrideFunc referenceOverride ReferenceOverrideFunc
@ -399,6 +399,7 @@ func Run(input []byte, opts ...Option) []byte {
// input markdown document and produces a syntax tree for its contents. This // input markdown document and produces a syntax tree for its contents. This
// tree can then be rendered with a default or custom renderer, or // tree can then be rendered with a default or custom renderer, or
// analyzed/transformed by the caller to whatever non-standard needs they have. // analyzed/transformed by the caller to whatever non-standard needs they have.
// The return value is the root node of the syntax tree.
func (p *Markdown) Parse(input []byte) *Node { func (p *Markdown) Parse(input []byte) *Node {
p.block(input) p.block(input)
// Walk the tree and finish up some of unfinished blocks // Walk the tree and finish up some of unfinished blocks