vendor/github.com/russross/blackfriday/v2/README.md
changeset 260 445e01aede7e
parent 256 6d9efbef00a9
equal deleted inserted replaced
259:db4911b0c721 260:445e01aede7e
     1 Blackfriday [![Build Status](https://travis-ci.org/russross/blackfriday.svg?branch=master)](https://travis-ci.org/russross/blackfriday)
     1 Blackfriday
       
     2 [![Build Status][BuildV2SVG]][BuildV2URL]
       
     3 [![PkgGoDev][PkgGoDevV2SVG]][PkgGoDevV2URL]
     2 ===========
     4 ===========
     3 
     5 
     4 Blackfriday is a [Markdown][1] processor implemented in [Go][2]. It
     6 Blackfriday is a [Markdown][1] processor implemented in [Go][2]. It
     5 is paranoid about its input (so you can safely feed it user-supplied
     7 is paranoid about its input (so you can safely feed it user-supplied
     6 data), it is fast, it supports common extensions (tables, smart
     8 data), it is fast, it supports common extensions (tables, smart
    14 
    16 
    15 
    17 
    16 Installation
    18 Installation
    17 ------------
    19 ------------
    18 
    20 
    19 Blackfriday is compatible with any modern Go release. With Go 1.7 and git
    21 Blackfriday is compatible with modern Go releases in module mode.
    20 installed:
    22 With Go installed:
    21 
    23 
    22     go get gopkg.in/russross/blackfriday.v2
    24     go get github.com/russross/blackfriday/v2
    23 
    25 
    24 will download, compile, and install the package into your `$GOPATH`
    26 will resolve and add the package to the current development module,
    25 directory hierarchy. Alternatively, you can achieve the same if you
    27 then build and install it. Alternatively, you can achieve the same
    26 import it into a project:
    28 if you import it in a package:
    27 
    29 
    28     import "gopkg.in/russross/blackfriday.v2"
    30     import "github.com/russross/blackfriday/v2"
    29 
    31 
    30 and `go get` without parameters.
    32 and `go get` without parameters.
       
    33 
       
    34 Legacy GOPATH mode is unsupported.
    31 
    35 
    32 
    36 
    33 Versions
    37 Versions
    34 --------
    38 --------
    35 
    39 
    36 Currently maintained and recommended version of Blackfriday is `v2`. It's being
    40 Currently maintained and recommended version of Blackfriday is `v2`. It's being
    37 developed on its own branch: https://github.com/russross/blackfriday/tree/v2 and the
    41 developed on its own branch: https://github.com/russross/blackfriday/tree/v2 and the
    38 documentation is available at
    42 documentation is available at
    39 https://godoc.org/gopkg.in/russross/blackfriday.v2.
    43 https://pkg.go.dev/github.com/russross/blackfriday/v2.
    40 
    44 
    41 It is `go get`-able via via [gopkg.in][6] at `gopkg.in/russross/blackfriday.v2`,
    45 It is `go get`-able in module mode at `github.com/russross/blackfriday/v2`.
    42 but we highly recommend using package management tool like [dep][7] or
       
    43 [Glide][8] and make use of semantic versioning. With package management you
       
    44 should import `github.com/russross/blackfriday` and specify that you're using
       
    45 version 2.0.0.
       
    46 
    46 
    47 Version 2 offers a number of improvements over v1:
    47 Version 2 offers a number of improvements over v1:
    48 
    48 
    49 * Cleaned up API
    49 * Cleaned up API
    50 * A separate call to [`Parse`][4], which produces an abstract syntax tree for
    50 * A separate call to [`Parse`][4], which produces an abstract syntax tree for
    60   and don't care too much about the new features, v2 is probably not for you.
    60   and don't care too much about the new features, v2 is probably not for you.
    61 * Several bug fixes are trailing behind and still need to be forward-ported to
    61 * Several bug fixes are trailing behind and still need to be forward-ported to
    62   v2. See issue [#348](https://github.com/russross/blackfriday/issues/348) for
    62   v2. See issue [#348](https://github.com/russross/blackfriday/issues/348) for
    63   tracking.
    63   tracking.
    64 
    64 
       
    65 If you are still interested in the legacy `v1`, you can import it from
       
    66 `github.com/russross/blackfriday`. Documentation for the legacy v1 can be found
       
    67 here: https://pkg.go.dev/github.com/russross/blackfriday.
       
    68 
       
    69 
    65 Usage
    70 Usage
    66 -----
    71 -----
    67 
    72 
    68 For the most sensible markdown processing, it is as simple as getting your input
    73 For the most sensible markdown processing, it is as simple as getting your input
    69 into a byte slice and calling:
    74 into a byte slice and calling:
    89 Here's an example of simple usage of Blackfriday together with Bluemonday:
    94 Here's an example of simple usage of Blackfriday together with Bluemonday:
    90 
    95 
    91 ```go
    96 ```go
    92 import (
    97 import (
    93     "github.com/microcosm-cc/bluemonday"
    98     "github.com/microcosm-cc/bluemonday"
    94     "github.com/russross/blackfriday"
    99     "github.com/russross/blackfriday/v2"
    95 )
   100 )
    96 
   101 
    97 // ...
   102 // ...
    98 unsafe := blackfriday.Run(input)
   103 unsafe := blackfriday.Run(input)
    99 html := bluemonday.UGCPolicy().SanitizeBytes(unsafe)
   104 html := bluemonday.UGCPolicy().SanitizeBytes(unsafe)
   102 ### Custom options
   107 ### Custom options
   103 
   108 
   104 If you want to customize the set of options, use `blackfriday.WithExtensions`,
   109 If you want to customize the set of options, use `blackfriday.WithExtensions`,
   105 `blackfriday.WithRenderer` and `blackfriday.WithRefOverride`.
   110 `blackfriday.WithRenderer` and `blackfriday.WithRefOverride`.
   106 
   111 
       
   112 ### `blackfriday-tool`
       
   113 
   107 You can also check out `blackfriday-tool` for a more complete example
   114 You can also check out `blackfriday-tool` for a more complete example
   108 of how to use it. Download and install it using:
   115 of how to use it. Download and install it using:
   109 
   116 
   110     go get github.com/russross/blackfriday-tool
   117     go get github.com/russross/blackfriday-tool
   111 
   118 
   112 This is a simple command-line tool that allows you to process a
   119 This is a simple command-line tool that allows you to process a
   113 markdown file using a standalone program.  You can also browse the
   120 markdown file using a standalone program.  You can also browse the
   114 source directly on github if you are just looking for some example
   121 source directly on github if you are just looking for some example
   115 code:
   122 code:
   116 
   123 
   117 * <http://github.com/russross/blackfriday-tool>
   124 * <https://github.com/russross/blackfriday-tool>
   118 
   125 
   119 Note that if you have not already done so, installing
   126 Note that if you have not already done so, installing
   120 `blackfriday-tool` will be sufficient to download and install
   127 `blackfriday-tool` will be sufficient to download and install
   121 blackfriday in addition to the tool itself. The tool binary will be
   128 blackfriday in addition to the tool itself. The tool binary will be
   122 installed in `$GOPATH/bin`.  This is a statically-linked binary that
   129 installed in `$GOPATH/bin`.  This is a statically-linked binary that
   123 can be copied to wherever you need it without worrying about
   130 can be copied to wherever you need it without worrying about
   124 dependencies and library versions.
   131 dependencies and library versions.
   125 
   132 
       
   133 ### Sanitized anchor names
       
   134 
       
   135 Blackfriday includes an algorithm for creating sanitized anchor names
       
   136 corresponding to a given input text. This algorithm is used to create
       
   137 anchors for headings when `AutoHeadingIDs` extension is enabled. The
       
   138 algorithm has a specification, so that other packages can create
       
   139 compatible anchor names and links to those anchors.
       
   140 
       
   141 The specification is located at https://pkg.go.dev/github.com/russross/blackfriday/v2#hdr-Sanitized_Anchor_Names.
       
   142 
       
   143 [`SanitizedAnchorName`](https://pkg.go.dev/github.com/russross/blackfriday/v2#SanitizedAnchorName) exposes this functionality, and can be used to
       
   144 create compatible links to the anchor names generated by blackfriday.
       
   145 This algorithm is also implemented in a small standalone package at
       
   146 [`github.com/shurcooL/sanitized_anchor_name`](https://pkg.go.dev/github.com/shurcooL/sanitized_anchor_name). It can be useful for clients
       
   147 that want a small package and don't need full functionality of blackfriday.
       
   148 
   126 
   149 
   127 Features
   150 Features
   128 --------
   151 --------
   129 
   152 
   130 All features of Sundown are supported, including:
   153 All features of Sundown are supported, including:
   197         ```
   220         ```
   198 
   221 
   199     You can use 3 or more backticks to mark the beginning of the
   222     You can use 3 or more backticks to mark the beginning of the
   200     block, and the same number to mark the end of the block.
   223     block, and the same number to mark the end of the block.
   201 
   224 
       
   225     To preserve classes of fenced code blocks while using the bluemonday
       
   226     HTML sanitizer, use the following policy:
       
   227 
       
   228     ```go
       
   229     p := bluemonday.UGCPolicy()
       
   230     p.AllowAttrs("class").Matching(regexp.MustCompile("^language-[a-zA-Z0-9]+$")).OnElements("code")
       
   231     html := p.SanitizeBytes(unsafe)
       
   232     ```
       
   233 
   202 *   **Definition lists**. A simple definition list is made of a single-line
   234 *   **Definition lists**. A simple definition list is made of a single-line
   203     term followed by a colon and the definition for that term.
   235     term followed by a colon and the definition for that term.
   204 
   236 
   205         Cat
   237         Cat
   206         : Fluffy animal everyone likes
   238         : Fluffy animal everyone likes
   248 ---------------
   280 ---------------
   249 
   281 
   250 Blackfriday is structured to allow alternative rendering engines. Here
   282 Blackfriday is structured to allow alternative rendering engines. Here
   251 are a few of note:
   283 are a few of note:
   252 
   284 
   253 *   [github_flavored_markdown](https://godoc.org/github.com/shurcooL/github_flavored_markdown):
   285 *   [github_flavored_markdown](https://pkg.go.dev/github.com/shurcooL/github_flavored_markdown):
   254     provides a GitHub Flavored Markdown renderer with fenced code block
   286     provides a GitHub Flavored Markdown renderer with fenced code block
   255     highlighting, clickable heading anchor links.
   287     highlighting, clickable heading anchor links.
   256 
   288 
   257     It's not customizable, and its goal is to produce HTML output
   289     It's not customizable, and its goal is to produce HTML output
   258     equivalent to the [GitHub Markdown API endpoint](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode),
   290     equivalent to the [GitHub Markdown API endpoint](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode),
   259     except the rendering is performed locally.
   291     except the rendering is performed locally.
   260 
   292 
   261 *   [markdownfmt](https://github.com/shurcooL/markdownfmt): like gofmt,
   293 *   [markdownfmt](https://github.com/shurcooL/markdownfmt): like gofmt,
   262     but for markdown.
   294     but for markdown.
   263 
   295 
   264 *   [LaTeX output](https://github.com/Ambrevar/Blackfriday-LaTeX):
   296 *   [LaTeX output](https://gitlab.com/ambrevar/blackfriday-latex):
   265     renders output as LaTeX.
   297     renders output as LaTeX.
   266 
   298 
       
   299 *   [bfchroma](https://github.com/Depado/bfchroma/): provides convenience
       
   300     integration with the [Chroma](https://github.com/alecthomas/chroma) code
       
   301     highlighting library. bfchroma is only compatible with v2 of Blackfriday and
       
   302     provides a drop-in renderer ready to use with Blackfriday, as well as
       
   303     options and means for further customization.
       
   304 
   267 *   [Blackfriday-Confluence](https://github.com/kentaro-m/blackfriday-confluence): provides a [Confluence Wiki Markup](https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html) renderer.
   305 *   [Blackfriday-Confluence](https://github.com/kentaro-m/blackfriday-confluence): provides a [Confluence Wiki Markup](https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html) renderer.
   268 
   306 
   269 
   307 *   [Blackfriday-Slack](https://github.com/karriereat/blackfriday-slack): converts markdown to slack message style
   270 Todo
   308 
       
   309 
       
   310 TODO
   271 ----
   311 ----
   272 
   312 
   273 *   More unit testing
   313 *   More unit testing
   274 *   Improve unicode support. It does not understand all unicode
   314 *   Improve Unicode support. It does not understand all Unicode
   275     rules (about what constitutes a letter, a punctuation symbol,
   315     rules (about what constitutes a letter, a punctuation symbol,
   276     etc.), so it may fail to detect word boundaries correctly in
   316     etc.), so it may fail to detect word boundaries correctly in
   277     some instances. It is safe on all utf-8 input.
   317     some instances. It is safe on all UTF-8 input.
   278 
   318 
   279 
   319 
   280 License
   320 License
   281 -------
   321 -------
   282 
   322 
   284 
   324 
   285 
   325 
   286    [1]: https://daringfireball.net/projects/markdown/ "Markdown"
   326    [1]: https://daringfireball.net/projects/markdown/ "Markdown"
   287    [2]: https://golang.org/ "Go Language"
   327    [2]: https://golang.org/ "Go Language"
   288    [3]: https://github.com/vmg/sundown "Sundown"
   328    [3]: https://github.com/vmg/sundown "Sundown"
   289    [4]: https://godoc.org/gopkg.in/russross/blackfriday.v2#Parse "Parse func"
   329    [4]: https://pkg.go.dev/github.com/russross/blackfriday/v2#Parse "Parse func"
   290    [5]: https://github.com/microcosm-cc/bluemonday "Bluemonday"
   330    [5]: https://github.com/microcosm-cc/bluemonday "Bluemonday"
   291    [6]: https://labix.org/gopkg.in "gopkg.in"
   331 
       
   332    [BuildV2SVG]: https://travis-ci.org/russross/blackfriday.svg?branch=v2
       
   333    [BuildV2URL]: https://travis-ci.org/russross/blackfriday
       
   334    [PkgGoDevV2SVG]: https://pkg.go.dev/badge/github.com/russross/blackfriday/v2
       
   335    [PkgGoDevV2URL]: https://pkg.go.dev/github.com/russross/blackfriday/v2