version number, few more options for command-line tool

pull/5/merge
Russ Ross 2011-06-28 11:30:10 -06:00
parent 84eeba2562
commit fde2c60665
11 changed files with 50 additions and 26 deletions

View File

@ -1,17 +1,17 @@
Blackfriday
===========
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.
Blackfriday is a [Markdown][1] processor implemented in [Go][2]. It
is paranoid about its input (so you can safely feed it user-supplied
data), it is fast, it supports common extensions (tables, smart
punctuation substitutions, etc.), and it is safe for all utf-8
(unicode) input.
HTML output is currently supported, along with Smartypants
extensions. An experimental LaTeX output engine is also included.
It started as a translation from C of [upskirt][3].
Installation
------------
@ -48,11 +48,12 @@ All features of upskirt are supported, including:
* Paranoid parsing, making it safe to feed untrusted used input
without fear of bad things happening. There are still some
corner cases that are untested, but it is already more strict
than upskirt (Go's bounds-checking uncovered a few off-by-one
errors that were present in the C code).
than upskirt (bounds checking in Go uncovered a few off-by-one
errors that were present in upskirt).
* Good performance. I have not done rigorous benchmarking, but
informal testing suggests it is around 3--4x slower than upskirt.
informal testing suggests it is around 3--4x slower than upskirt
for general input. It blows away most other markdown processors.
* Minimal dependencies. Blackfriday only depends on standard
library packages in Go. The source code is pretty
@ -96,6 +97,10 @@ Todo
* Code cleanup
* Better code documentation
* Markdown pretty-printer output engine
* Improve unicode support. It does not understand all unicode
rules (about what constitutes a letter, a punctuation symbol,
etc.), so it may fail to detect word boundaries correctly in
some instances. It is safe on all utf-8 input.
License

View File

@ -3,7 +3,7 @@
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 Russ Ross <russ@russross.com>.
// Licensed under the Simplified BSD License.
// Distributed under the Simplified BSD License.
// See README.md for details.
//

View File

@ -3,7 +3,7 @@
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 Russ Ross <russ@russross.com>.
// Licensed under the Simplified BSD License.
// Distributed under the Simplified BSD License.
// See README.md for details.
//

View File

@ -3,7 +3,7 @@
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 Russ Ross <russ@russross.com>.
// Licensed under the Simplified BSD License.
// Distributed under the Simplified BSD License.
// See README.md for details.
//
@ -27,7 +27,7 @@ import (
func main() {
// parse command-line options
var page, xhtml, latex, smartypants bool
var page, xhtml, latex, smartypants, latexdashes, fractions bool
var css, cpuprofile string
var repeat int
flag.BoolVar(&page, "page", false,
@ -36,8 +36,12 @@ func main() {
"Use XHTML-style tags in HTML output")
flag.BoolVar(&latex, "latex", false,
"Generate LaTeX output instead of HTML")
flag.BoolVar(&smartypants, "smartypants", false,
flag.BoolVar(&smartypants, "smartypants", true,
"Apply smartypants-style substitutions")
flag.BoolVar(&latexdashes, "latexdashes", true,
"Use LaTeX-style dash rules for smartypants")
flag.BoolVar(&fractions, "fractions", true,
"Use improved fraction rules for smartypants")
flag.StringVar(&css, "css", "",
"Link to a CSS stylesheet (implies -page)")
flag.StringVar(&cpuprofile, "cpuprofile", "",
@ -45,7 +49,12 @@ func main() {
flag.IntVar(&repeat, "repeat", 1,
"Process the input multiple times (for benchmarking)")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage:\n"+
fmt.Fprintf(os.Stderr, "Blackfriday Markdown Processor v"+blackfriday.VERSION+
"\nAvailable at http://github.com/russross/blackfriday\n\n"+
"Copyright © 2011 Russ Ross <russ@russross.com>\n"+
"Distributed under the Simplified BSD License\n"+
"See website for details\n\n"+
"Usage:\n"+
" %s [options] [inputfile [outputfile]]\n\n"+
"Options:\n",os.Args[0])
flag.PrintDefaults()
@ -111,7 +120,11 @@ func main() {
}
if smartypants {
html_flags |= blackfriday.HTML_USE_SMARTYPANTS
}
if fractions {
html_flags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS
}
if latexdashes {
html_flags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES
}
renderer = blackfriday.HtmlRenderer(html_flags)
@ -162,8 +175,10 @@ func main() {
}
fmt.Fprintln(out, "<head>")
fmt.Fprintf(out, " <title>%s</title>\n", title)
fmt.Fprintf(out, " <meta name=\"GENERATOR\" content=\"Blackfriday markdown processor\"%s>\n", ending)
fmt.Fprintf(out, " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"%s>\n", ending)
fmt.Fprintf(out, " <meta name=\"GENERATOR\" content=\"Blackfriday Markdown Processor v%s\"%s>\n",
blackfriday.VERSION, ending)
fmt.Fprintf(out, " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"%s>\n",
ending)
if css != "" {
fmt.Fprintf(out, " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n", css)
}

View File

@ -3,7 +3,7 @@
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 Russ Ross <russ@russross.com>.
// Licensed under the Simplified BSD License.
// Distributed under the Simplified BSD License.
// See README.md for details.
//

View File

@ -3,7 +3,7 @@
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 Russ Ross <russ@russross.com>.
// Licensed under the Simplified BSD License.
// Distributed under the Simplified BSD License.
// See README.md for details.
//

View File

@ -3,7 +3,7 @@
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 Russ Ross <russ@russross.com>.
// Licensed under the Simplified BSD License.
// Distributed under the Simplified BSD License.
// See README.md for details.
//

View File

@ -3,7 +3,7 @@
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 Russ Ross <russ@russross.com>.
// Licensed under the Simplified BSD License.
// Distributed under the Simplified BSD License.
// See README.md for details.
//
@ -307,7 +307,9 @@ func latexDocumentHeader(out *bytes.Buffer, opaque interface{}) {
out.WriteString(" urlcolor=black,%\n")
out.WriteString(" pdfstartview=FitH,%\n")
out.WriteString(" breaklinks=true,%\n")
out.WriteString(" pdfauthor={Blackfriday Markdown Processor}}\n")
out.WriteString(" pdfauthor={Blackfriday Markdown Processor v")
out.WriteString(VERSION)
out.WriteString("}}\n")
out.WriteString("\n")
out.WriteString("\\newcommand{\\HRule}{\\rule{\\linewidth}{0.5mm}}\n")
out.WriteString("\\addtolength{\\parskip}{0.5\\baselineskip}\n")

View File

@ -3,7 +3,7 @@
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 Russ Ross <russ@russross.com>.
// Licensed under the Simplified BSD License.
// Distributed under the Simplified BSD License.
// See README.md for details.
//
@ -20,6 +20,8 @@ import (
"utf8"
)
const VERSION = "0.5"
// These are the supported markdown parsing extensions.
// OR these values together to select multiple extensions.
const (

View File

@ -3,7 +3,7 @@
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 Russ Ross <russ@russross.com>.
// Licensed under the Simplified BSD License.
// Distributed under the Simplified BSD License.
// See README.md for details.
//

View File

@ -3,7 +3,7 @@
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 Russ Ross <russ@russross.com>.
// Licensed under the Simplified BSD License.
// Distributed under the Simplified BSD License.
// See README.md for details.
//