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
6
Blackfriday is a [ Markdown] [ 1 ] processor implemented in [ Go] [ 2 ] . It
@@ -16,33 +18,31 @@ It started as a translation from C of [Sundown][3].
16
18
Installation
17
19
------------
18
20
19
- Blackfriday is compatible with any modern Go release. With Go 1.7 and git
20
- installed:
21
+ Blackfriday is compatible with modern Go releases in module mode.
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 `
25
- directory hierarchy . Alternatively, you can achieve the same if you
26
- import it into a project :
26
+ will resolve and add the package to the current development module,
27
+ then build and install it . Alternatively, you can achieve the same
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
32
and ` go get ` without parameters.
31
33
34
+ Legacy GOPATH mode is unsupported.
35
+
32
36
33
37
Versions
34
38
--------
35
39
36
40
Currently maintained and recommended version of Blackfriday is ` v2 ` . It's being
37
41
developed on its own branch: https://github.com/russross/blackfriday/tree/v2 and the
38
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 ` ,
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.
45
+ It is ` go get ` -able in module mode at ` github.com/russross/blackfriday/v2 ` .
46
46
47
47
Version 2 offers a number of improvements over v1:
48
48
@@ -62,6 +62,11 @@ Potential drawbacks:
62
62
v2. See issue [ #348 ] ( https://github.com/russross/blackfriday/issues/348 ) for
63
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
70
Usage
66
71
-----
67
72
@@ -91,7 +96,7 @@ Here's an example of simple usage of Blackfriday together with Bluemonday:
91
96
``` go
92
97
import (
93
98
" github.com/microcosm-cc/bluemonday"
94
- " github.com/russross/blackfriday"
99
+ " github.com/russross/blackfriday/v2 "
95
100
)
96
101
97
102
// ...
@@ -116,7 +121,7 @@ markdown file using a standalone program. You can also browse the
116
121
source directly on github if you are just looking for some example
117
122
code:
118
123
119
- * < http ://github.com/russross/blackfriday-tool>
124
+ * < https ://github.com/russross/blackfriday-tool>
120
125
121
126
Note that if you have not already done so, installing
122
127
` blackfriday-tool ` will be sufficient to download and install
@@ -133,12 +138,12 @@ anchors for headings when `AutoHeadingIDs` extension is enabled. The
133
138
algorithm has a specification, so that other packages can create
134
139
compatible anchor names and links to those anchors.
135
140
136
- The specification is located at https://godoc.org/gopkg.in /russross/blackfriday. v2#hdr-Sanitized_Anchor_Names .
141
+ The specification is located at https://pkg.go.dev/github.com /russross/blackfriday/ v2#hdr-Sanitized_Anchor_Names .
137
142
138
- [ ` SanitizedAnchorName ` ] ( https://godoc.org/gopkg.in /russross/blackfriday. v2#SanitizedAnchorName ) exposes this functionality, and can be used to
143
+ [ ` SanitizedAnchorName ` ] ( https://pkg.go.dev/github.com /russross/blackfriday/ v2#SanitizedAnchorName ) exposes this functionality, and can be used to
139
144
create compatible links to the anchor names generated by blackfriday.
140
145
This algorithm is also implemented in a small standalone package at
141
- [ ` github.com/shurcooL/sanitized_anchor_name ` ] ( https://godoc.org /github.com/shurcooL/sanitized_anchor_name ) . It can be useful for clients
146
+ [ ` github.com/shurcooL/sanitized_anchor_name ` ] ( https://pkg.go.dev /github.com/shurcooL/sanitized_anchor_name ) . It can be useful for clients
142
147
that want a small package and don't need full functionality of blackfriday.
143
148
144
149
@@ -217,6 +222,15 @@ implements the following extensions:
217
222
You can use 3 or more backticks to mark the beginning of the
218
223
block, and the same number to mark the end of the block.
219
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
+
220
234
* **Definition lists**. A simple definition list is made of a single-line
221
235
term followed by a colon and the definition for that term.
222
236
@@ -268,7 +282,7 @@ Other renderers
268
282
Blackfriday is structured to allow alternative rendering engines. Here
269
283
are a few of note:
270
284
271
- * [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):
272
286
provides a GitHub Flavored Markdown renderer with fenced code block
273
287
highlighting, clickable heading anchor links.
274
288
@@ -279,21 +293,28 @@ are a few of note:
279
293
* [markdownfmt](https://github.com/shurcooL/markdownfmt): like gofmt,
280
294
but for markdown.
281
295
282
- * [LaTeX output](https://github .com/Ambrevar/Blackfriday-LaTeX ):
296
+ * [LaTeX output](https://gitlab .com/ambrevar/blackfriday-latex ):
283
297
renders output as LaTeX.
284
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
+
285
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.
286
306
287
307
* [Blackfriday-Slack](https://github.com/karriereat/blackfriday-slack): converts markdown to slack message style
288
308
289
- Todo
309
+
310
+ TODO
290
311
----
291
312
292
313
* More unit testing
293
- * Improve unicode support. It does not understand all unicode
314
+ * Improve Unicode support. It does not understand all Unicode
294
315
rules (about what constitutes a letter, a punctuation symbol,
295
316
etc.), so it may fail to detect word boundaries correctly in
296
- some instances. It is safe on all utf -8 input.
317
+ some instances. It is safe on all UTF -8 input.
297
318
298
319
299
320
License
@@ -305,6 +326,10 @@ License
305
326
[1]: https://daringfireball.net/projects/markdown/ "Markdown"
306
327
[2]: https://golang.org/ "Go Language"
307
328
[3]: https://github.com/vmg/sundown "Sundown"
308
- [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"
309
330
[5]: https://github.com/microcosm-cc/bluemonday "Bluemonday"
310
- [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
0 commit comments