From 9a11e9663315629a72612dd4bd351b48001db90d Mon Sep 17 00:00:00 2001 From: Russ Ross Date: Sat, 28 May 2011 21:33:16 -0600 Subject: [PATCH] readme file --- Makefile | 5 +++++ README.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ smartypants.go | 4 +++- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/Makefile b/Makefile index bc3050d..e9c160a 100644 --- a/Makefile +++ b/Makefile @@ -4,4 +4,9 @@ TARG=github.com/russross/blackfriday GOFILES=markdown.go html.go smartypants.go +package: + include $(GOROOT)/src/Make.pkg + +markdown: package + make -C example diff --git a/README.md b/README.md new file mode 100644 index 0000000..2f467f4 --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +Black Friday +============ + +This is an implementation of John Gruber's [markdown][1] in [Go][2]. +It is a translation of the [upskirt][3] library written in C with a +few minor changes. It retains the paranoia of the original (it is +careful not to trust its input, and as such it should be safe to +feed it arbitrary user-supplied inputs). It also retains the +emphasis on high performance, and the source is almost as ugly as +the original. + +HTML output is currently supported, along with Smartpants +extensions. + + +Installation +------------ + +Assuming you have recent version of Go installed, along with git: + + goinstall github.com/russross/blackfriday + +will download, compile, and install the package into +`$GOROOT/src/pkg/github.com/russross/blackfriday`. + +Check out `example/main.go` for an example of how to use it. Run +`gomake` in that directory to build a simple command-line markdown +tool: + + cd $GOROOT/src/pkg/github.com/russross/blackfriday + gomake markdown + +will build the binary `markdown` in the `example` directory. + + +Extensions +---------- + +In addition to the extensions offered by upskirt, this package +implements two additional Smartypants options: + +* LaTeX-style dash parsing, where `--` is translated into + `–` +* Generic fractions, where anything that looks like a fraction + is translated into suitable HTML (instead of just a few special + cases). For example, `4/5` becomes `45` + + +Todo +---- + +* Code cleanup +* Better code documentation +* Implement a LaTeX backend + + + [1]: http://daringfireball.net/projects/markdown/ "Markdown" + [2]: http://golang.org/ "Go Language" + [3]: http://github.com/tanoku/upskirt "Upskirt" diff --git a/smartypants.go b/smartypants.go index 31909c5..745e8d6 100644 --- a/smartypants.go +++ b/smartypants.go @@ -231,9 +231,11 @@ func smartypants_cb__number_generic(ob *bytes.Buffer, smrt *smartypants_data, pr return 0 } if len(text) == den_end || word_boundary(text[den_end]) { + ob.WriteString("") ob.Write(text[:num_end]) - ob.WriteString("⁄") + ob.WriteString("") ob.Write(text[num_end+1 : den_end]) + ob.WriteString("") return den_end - 1 } }