Skip to content
This repository was archived by the owner on Aug 27, 2018. It is now read-only.

Commit dce30b5

Browse files
committed
First cut of JSX-like support
1 parent 63772bd commit dce30b5

File tree

598 files changed

+162131
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

598 files changed

+162131
-141
lines changed

.vendor.txt

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
./_vendor/src/golang.org/x/sys 9a7256cb28ed514b4e1e5f68959914c4c28a92e0 https://go.googlesource.com/sys
2-
./_vendor/src/golang.org/x/crypto 3cb07270c9455e8ad27956a70891c962d121a228 https://go.googlesource.com/crypto
3-
./_vendor/src/golang.org/x/tools 620ecdb8d7943e20dc030b61bfe898d1b000bdea https://go.googlesource.com/tools
4-
./_vendor/src/github.com/gopherjs/gopherjs 9659c814f1d54d63f9c623449a7111d3864c1361 git@github.com:gopherjs/gopherjs
5-
./_vendor/src/github.com/kisielk/gotool 0de1eaf82fa3f583ce21fde859f1e7e0c5e9b220 git@github.com:kisielk/gotool
6-
./_vendor/src/github.com/fsnotify/fsnotify 7d7316ed6e1ed2de075aab8dfc76de5d158d66e1 git@github.com:fsnotify/fsnotify
7-
./_vendor/src/github.com/spf13/cobra 16c014f1a19d865b765b420e74508f80eb831ada git@github.com:spf13/cobra
8-
./_vendor/src/github.com/spf13/pflag 9ff6c6923cfffbcd502984b8e0c80539a94968b7 git@github.com:spf13/pflag
9-
./_vendor/src/github.com/kardianos/osext 9d302b58e975387d0b4d9be876622c86cefe64be git@github.com:kardianos/osext
10-
./_vendor/src/github.com/neelance/astrewrite 99348263ae862cc230986ce88deaddbf7edcc034 git@github.com:neelance/astrewrite
11-
./_vendor/src/github.com/neelance/sourcemap 8c68805598ab8d5637b1a72b5f7d381ea0f39c31 git@github.com:neelance/sourcemap
12-
./_vendor/src/myitcv.io/highlightjs e0ea663591fbdbce10ca2658c680ba7be2391ff8 git@github.com:myitcv/highlightjs
13-
./_vendor/src/myitcv.io/gogenerate bd69a94c96953d20e106734856b69d71c8fa122b git@github.com:myitcv/gogenerate
14-
./_vendor/src/myitcv.io/remarkable 6e8b85d04c0c2559fec23559cf88780db6d93083 git@github.com:myitcv/remarkable
15-
./_vendor/src/myitcv.io/sorter ed1d278951e48d5c8e355c266faec8666d40b2b3 git@github.com:myitcv/sorter
16-
./_vendor/src/myitcv.io/immutable 74c4e0dc47c184000811bee5bb1bb293c5b2b674 git@github.com:myitcv/immutable
17-
./_vendor/src/honnef.co/go/js/xhr 00e3346113aed89b501ead4e863c7c3d04fa0c5b git@github.com:dominikh/go-js-xhr
18-
./_vendor/src/honnef.co/go/js/util 96b8dd9d16214b6cd9d8c8e84b3a375da4688108 git@github.com:dominikh/go-js-util
19-
./_vendor/src/honnef.co/go/js/dom 0a64a2db1425c1881d4ec762370250c65f44b85b git@github.com:dominikh/go-js-dom
1+
./_vendor/src/golang.org/x/net da118f7b8e5954f39d0d2130ab35d4bf0e3cb344 https://go.googlesource.com/net
2+
./_vendor/src/golang.org/x/sys 9a7256cb28ed514b4e1e5f68959914c4c28a92e0 https://go.googlesource.com/sys
3+
./_vendor/src/golang.org/x/crypto 3cb07270c9455e8ad27956a70891c962d121a228 https://go.googlesource.com/crypto
4+
./_vendor/src/golang.org/x/tools 620ecdb8d7943e20dc030b61bfe898d1b000bdea https://go.googlesource.com/tools
5+
./_vendor/src/github.com/gopherjs/gopherjs 9659c814f1d54d63f9c623449a7111d3864c1361 git@github.com:gopherjs/gopherjs
6+
./_vendor/src/github.com/kisielk/gotool 0de1eaf82fa3f583ce21fde859f1e7e0c5e9b220 git@github.com:kisielk/gotool
7+
./_vendor/src/github.com/fsnotify/fsnotify 7d7316ed6e1ed2de075aab8dfc76de5d158d66e1 git@github.com:fsnotify/fsnotify
8+
./_vendor/src/github.com/spf13/cobra 16c014f1a19d865b765b420e74508f80eb831ada git@github.com:spf13/cobra
9+
./_vendor/src/github.com/spf13/pflag 9ff6c6923cfffbcd502984b8e0c80539a94968b7 git@github.com:spf13/pflag
10+
./_vendor/src/github.com/kardianos/osext 9d302b58e975387d0b4d9be876622c86cefe64be git@github.com:kardianos/osext
11+
./_vendor/src/github.com/neelance/astrewrite 99348263ae862cc230986ce88deaddbf7edcc034 git@github.com:neelance/astrewrite
12+
./_vendor/src/github.com/neelance/sourcemap 8c68805598ab8d5637b1a72b5f7d381ea0f39c31 git@github.com:neelance/sourcemap
13+
./_vendor/src/github.com/shurcooL/sanitized_anchor_name 79c90efaf01eddc01945af5bc1797859189b830b git@github.com:shurcooL/sanitized_anchor_name
14+
./_vendor/src/github.com/russross/blackfriday b253417e1cb644d645a0a3bb1fa5034c8030127c git@github.com:russross/blackfriday
15+
./_vendor/src/myitcv.io/highlightjs e0ea663591fbdbce10ca2658c680ba7be2391ff8 git@github.com:myitcv/highlightjs
16+
./_vendor/src/myitcv.io/gogenerate bd69a94c96953d20e106734856b69d71c8fa122b git@github.com:myitcv/gogenerate
17+
./_vendor/src/myitcv.io/remarkable 6e8b85d04c0c2559fec23559cf88780db6d93083 git@github.com:myitcv/remarkable
18+
./_vendor/src/myitcv.io/sorter ed1d278951e48d5c8e355c266faec8666d40b2b3 git@github.com:myitcv/sorter
19+
./_vendor/src/myitcv.io/immutable 74c4e0dc47c184000811bee5bb1bb293c5b2b674 git@github.com:myitcv/immutable
20+
./_vendor/src/honnef.co/go/js/xhr 00e3346113aed89b501ead4e863c7c3d04fa0c5b git@github.com:dominikh/go-js-xhr
21+
./_vendor/src/honnef.co/go/js/util 96b8dd9d16214b6cd9d8c8e84b3a375da4688108 git@github.com:dominikh/go-js-util
22+
./_vendor/src/honnef.co/go/js/dom 0a64a2db1425c1881d4ec762370250c65f44b85b git@github.com:dominikh/go-js-dom
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.out
2+
*.swp
3+
*.8
4+
*.6
5+
_obj
6+
_test*
7+
markdown
8+
tags
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
sudo: false
2+
language: go
3+
go:
4+
- 1.5.4
5+
- 1.6.2
6+
- tip
7+
matrix:
8+
include:
9+
- go: 1.2.2
10+
script:
11+
- go get -t -v ./...
12+
- go test -v -race ./...
13+
- go: 1.3.3
14+
script:
15+
- go get -t -v ./...
16+
- go test -v -race ./...
17+
- go: 1.4.3
18+
script:
19+
- go get -t -v ./...
20+
- go test -v -race ./...
21+
allow_failures:
22+
- go: tip
23+
fast_finish: true
24+
install:
25+
- # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step).
26+
script:
27+
- go get -t -v ./...
28+
- diff -u <(echo -n) <(gofmt -d -s .)
29+
- go tool vet .
30+
- go test -v -race ./...
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Blackfriday is distributed under the Simplified BSD License:
2+
3+
> Copyright © 2011 Russ Ross
4+
> All rights reserved.
5+
>
6+
> Redistribution and use in source and binary forms, with or without
7+
> modification, are permitted provided that the following conditions
8+
> are met:
9+
>
10+
> 1. Redistributions of source code must retain the above copyright
11+
> notice, this list of conditions and the following disclaimer.
12+
>
13+
> 2. Redistributions in binary form must reproduce the above
14+
> copyright notice, this list of conditions and the following
15+
> disclaimer in the documentation and/or other materials provided with
16+
> the distribution.
17+
>
18+
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
> "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
> LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21+
> FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22+
> COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23+
> INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
> BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25+
> LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27+
> LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28+
> ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29+
> POSSIBILITY OF SUCH DAMAGE.
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
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)
2+
===========
3+
4+
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
6+
data), it is fast, it supports common extensions (tables, smart
7+
punctuation substitutions, etc.), and it is safe for all utf-8
8+
(unicode) input.
9+
10+
HTML output is currently supported, along with Smartypants
11+
extensions. An experimental LaTeX output engine is also included.
12+
13+
It started as a translation from C of [Sundown][3].
14+
15+
16+
Installation
17+
------------
18+
19+
Blackfriday is compatible with Go 1. If you are using an older
20+
release of Go, consider using v1.1 of blackfriday, which was based
21+
on the last stable release of Go prior to Go 1. You can find it as a
22+
tagged commit on github.
23+
24+
With Go 1 and git installed:
25+
26+
go get github.com/russross/blackfriday
27+
28+
will download, compile, and install the package into your `$GOPATH`
29+
directory hierarchy. Alternatively, you can achieve the same if you
30+
import it into a project:
31+
32+
import "github.com/russross/blackfriday"
33+
34+
and `go get` without parameters.
35+
36+
Usage
37+
-----
38+
39+
For basic usage, it is as simple as getting your input into a byte
40+
slice and calling:
41+
42+
output := blackfriday.MarkdownBasic(input)
43+
44+
This renders it with no extensions enabled. To get a more useful
45+
feature set, use this instead:
46+
47+
output := blackfriday.MarkdownCommon(input)
48+
49+
### Sanitize untrusted content
50+
51+
Blackfriday itself does nothing to protect against malicious content. If you are
52+
dealing with user-supplied markdown, we recommend running blackfriday's output
53+
through HTML sanitizer such as
54+
[Bluemonday](https://github.com/microcosm-cc/bluemonday).
55+
56+
Here's an example of simple usage of blackfriday together with bluemonday:
57+
58+
``` go
59+
import (
60+
"github.com/microcosm-cc/bluemonday"
61+
"github.com/russross/blackfriday"
62+
)
63+
64+
// ...
65+
unsafe := blackfriday.MarkdownCommon(input)
66+
html := bluemonday.UGCPolicy().SanitizeBytes(unsafe)
67+
```
68+
69+
### Custom options
70+
71+
If you want to customize the set of options, first get a renderer
72+
(currently either the HTML or LaTeX output engines), then use it to
73+
call the more general `Markdown` function. For examples, see the
74+
implementations of `MarkdownBasic` and `MarkdownCommon` in
75+
`markdown.go`.
76+
77+
You can also check out `blackfriday-tool` for a more complete example
78+
of how to use it. Download and install it using:
79+
80+
go get github.com/russross/blackfriday-tool
81+
82+
This is a simple command-line tool that allows you to process a
83+
markdown file using a standalone program. You can also browse the
84+
source directly on github if you are just looking for some example
85+
code:
86+
87+
* <http://github.com/russross/blackfriday-tool>
88+
89+
Note that if you have not already done so, installing
90+
`blackfriday-tool` will be sufficient to download and install
91+
blackfriday in addition to the tool itself. The tool binary will be
92+
installed in `$GOPATH/bin`. This is a statically-linked binary that
93+
can be copied to wherever you need it without worrying about
94+
dependencies and library versions.
95+
96+
97+
Features
98+
--------
99+
100+
All features of Sundown are supported, including:
101+
102+
* **Compatibility**. The Markdown v1.0.3 test suite passes with
103+
the `--tidy` option. Without `--tidy`, the differences are
104+
mostly in whitespace and entity escaping, where blackfriday is
105+
more consistent and cleaner.
106+
107+
* **Common extensions**, including table support, fenced code
108+
blocks, autolinks, strikethroughs, non-strict emphasis, etc.
109+
110+
* **Safety**. Blackfriday is paranoid when parsing, making it safe
111+
to feed untrusted user input without fear of bad things
112+
happening. The test suite stress tests this and there are no
113+
known inputs that make it crash. If you find one, please let me
114+
know and send me the input that does it.
115+
116+
NOTE: "safety" in this context means *runtime safety only*. In order to
117+
protect yourself against JavaScript injection in untrusted content, see
118+
[this example](https://github.com/russross/blackfriday#sanitize-untrusted-content).
119+
120+
* **Fast processing**. It is fast enough to render on-demand in
121+
most web applications without having to cache the output.
122+
123+
* **Thread safety**. You can run multiple parsers in different
124+
goroutines without ill effect. There is no dependence on global
125+
shared state.
126+
127+
* **Minimal dependencies**. Blackfriday only depends on standard
128+
library packages in Go. The source code is pretty
129+
self-contained, so it is easy to add to any project, including
130+
Google App Engine projects.
131+
132+
* **Standards compliant**. Output successfully validates using the
133+
W3C validation tool for HTML 4.01 and XHTML 1.0 Transitional.
134+
135+
136+
Extensions
137+
----------
138+
139+
In addition to the standard markdown syntax, this package
140+
implements the following extensions:
141+
142+
* **Intra-word emphasis supression**. The `_` character is
143+
commonly used inside words when discussing code, so having
144+
markdown interpret it as an emphasis command is usually the
145+
wrong thing. Blackfriday lets you treat all emphasis markers as
146+
normal characters when they occur inside a word.
147+
148+
* **Tables**. Tables can be created by drawing them in the input
149+
using a simple syntax:
150+
151+
```
152+
Name | Age
153+
--------|------
154+
Bob | 27
155+
Alice | 23
156+
```
157+
158+
* **Fenced code blocks**. In addition to the normal 4-space
159+
indentation to mark code blocks, you can explicitly mark them
160+
and supply a language (to make syntax highlighting simple). Just
161+
mark it like this:
162+
163+
``` go
164+
func getTrue() bool {
165+
return true
166+
}
167+
```
168+
169+
You can use 3 or more backticks to mark the beginning of the
170+
block, and the same number to mark the end of the block.
171+
172+
To preserve classes of fenced code blocks while using the bluemonday
173+
HTML sanitizer, use the following policy:
174+
175+
``` go
176+
p := bluemonday.UGCPolicy()
177+
p.AllowAttrs("class").Matching(regexp.MustCompile("^language-[a-zA-Z0-9]+$")).OnElements("code")
178+
html := p.SanitizeBytes(unsafe)
179+
```
180+
181+
* **Definition lists**. A simple definition list is made of a single-line
182+
term followed by a colon and the definition for that term.
183+
184+
Cat
185+
: Fluffy animal everyone likes
186+
187+
Internet
188+
: Vector of transmission for pictures of cats
189+
190+
Terms must be separated from the previous definition by a blank line.
191+
192+
* **Footnotes**. A marker in the text that will become a superscript number;
193+
a footnote definition that will be placed in a list of footnotes at the
194+
end of the document. A footnote looks like this:
195+
196+
This is a footnote.[^1]
197+
198+
[^1]: the footnote text.
199+
200+
* **Autolinking**. Blackfriday can find URLs that have not been
201+
explicitly marked as links and turn them into links.
202+
203+
* **Strikethrough**. Use two tildes (`~~`) to mark text that
204+
should be crossed out.
205+
206+
* **Hard line breaks**. With this extension enabled (it is off by
207+
default in the `MarkdownBasic` and `MarkdownCommon` convenience
208+
functions), newlines in the input translate into line breaks in
209+
the output.
210+
211+
* **Smart quotes**. Smartypants-style punctuation substitution is
212+
supported, turning normal double- and single-quote marks into
213+
curly quotes, etc.
214+
215+
* **LaTeX-style dash parsing** is an additional option, where `--`
216+
is translated into `&ndash;`, and `---` is translated into
217+
`&mdash;`. This differs from most smartypants processors, which
218+
turn a single hyphen into an ndash and a double hyphen into an
219+
mdash.
220+
221+
* **Smart fractions**, where anything that looks like a fraction
222+
is translated into suitable HTML (instead of just a few special
223+
cases like most smartypant processors). For example, `4/5`
224+
becomes `<sup>4</sup>&frasl;<sub>5</sub>`, which renders as
225+
<sup>4</sup>&frasl;<sub>5</sub>.
226+
227+
228+
Other renderers
229+
---------------
230+
231+
Blackfriday is structured to allow alternative rendering engines. Here
232+
are a few of note:
233+
234+
* [github_flavored_markdown](https://godoc.org/github.com/shurcooL/github_flavored_markdown):
235+
provides a GitHub Flavored Markdown renderer with fenced code block
236+
highlighting, clickable header anchor links.
237+
238+
It's not customizable, and its goal is to produce HTML output
239+
equivalent to the [GitHub Markdown API endpoint](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode),
240+
except the rendering is performed locally.
241+
242+
* [markdownfmt](https://github.com/shurcooL/markdownfmt): like gofmt,
243+
but for markdown.
244+
245+
* LaTeX output: renders output as LaTeX. This is currently part of the
246+
main Blackfriday repository, but may be split into its own project
247+
in the future. If you are interested in owning and maintaining the
248+
LaTeX output component, please be in touch.
249+
250+
It renders some basic documents, but is only experimental at this
251+
point. In particular, it does not do any inline escaping, so input
252+
that happens to look like LaTeX code will be passed through without
253+
modification.
254+
255+
* [Md2Vim](https://github.com/FooSoft/md2vim): transforms markdown files into vimdoc format.
256+
257+
258+
Todo
259+
----
260+
261+
* More unit testing
262+
* Improve unicode support. It does not understand all unicode
263+
rules (about what constitutes a letter, a punctuation symbol,
264+
etc.), so it may fail to detect word boundaries correctly in
265+
some instances. It is safe on all utf-8 input.
266+
267+
268+
License
269+
-------
270+
271+
[Blackfriday is distributed under the Simplified BSD License](LICENSE.txt)
272+
273+
274+
[1]: http://daringfireball.net/projects/markdown/ "Markdown"
275+
[2]: http://golang.org/ "Go Language"
276+
[3]: https://github.com/vmg/sundown "Sundown"

0 commit comments

Comments
 (0)