From fde2c60665de643152ebbfb4fc9e8b83da09cadf Mon Sep 17 00:00:00 2001 From: Russ Ross Date: Tue, 28 Jun 2011 11:30:10 -0600 Subject: [PATCH] version number, few more options for command-line tool --- README.md | 25 +++++++++++++++---------- block.go | 2 +- block_test.go | 2 +- example/main.go | 27 +++++++++++++++++++++------ html.go | 2 +- inline.go | 2 +- inline_test.go | 2 +- latex.go | 6 ++++-- markdown.go | 4 +++- smartypants.go | 2 +- upskirtref_test.go | 2 +- 11 files changed, 50 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index d76db8f..cdbdc99 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/block.go b/block.go index efd1d32..42fb212 100644 --- a/block.go +++ b/block.go @@ -3,7 +3,7 @@ // Available at http://github.com/russross/blackfriday // // Copyright © 2011 Russ Ross . -// Licensed under the Simplified BSD License. +// Distributed under the Simplified BSD License. // See README.md for details. // diff --git a/block_test.go b/block_test.go index 358ab0b..37e75be 100644 --- a/block_test.go +++ b/block_test.go @@ -3,7 +3,7 @@ // Available at http://github.com/russross/blackfriday // // Copyright © 2011 Russ Ross . -// Licensed under the Simplified BSD License. +// Distributed under the Simplified BSD License. // See README.md for details. // diff --git a/example/main.go b/example/main.go index 7d2e54b..e89aa9d 100644 --- a/example/main.go +++ b/example/main.go @@ -3,7 +3,7 @@ // Available at http://github.com/russross/blackfriday // // Copyright © 2011 Russ Ross . -// 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 \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, "") fmt.Fprintf(out, " %s\n", title) - fmt.Fprintf(out, " \n", ending) - fmt.Fprintf(out, " \n", ending) + fmt.Fprintf(out, " \n", + blackfriday.VERSION, ending) + fmt.Fprintf(out, " \n", + ending) if css != "" { fmt.Fprintf(out, " \n", css) } diff --git a/html.go b/html.go index a301097..380fa33 100644 --- a/html.go +++ b/html.go @@ -3,7 +3,7 @@ // Available at http://github.com/russross/blackfriday // // Copyright © 2011 Russ Ross . -// Licensed under the Simplified BSD License. +// Distributed under the Simplified BSD License. // See README.md for details. // diff --git a/inline.go b/inline.go index da20800..4e8196f 100644 --- a/inline.go +++ b/inline.go @@ -3,7 +3,7 @@ // Available at http://github.com/russross/blackfriday // // Copyright © 2011 Russ Ross . -// Licensed under the Simplified BSD License. +// Distributed under the Simplified BSD License. // See README.md for details. // diff --git a/inline_test.go b/inline_test.go index 957cfee..8ce7046 100644 --- a/inline_test.go +++ b/inline_test.go @@ -3,7 +3,7 @@ // Available at http://github.com/russross/blackfriday // // Copyright © 2011 Russ Ross . -// Licensed under the Simplified BSD License. +// Distributed under the Simplified BSD License. // See README.md for details. // diff --git a/latex.go b/latex.go index 9c1935a..d1ba18a 100644 --- a/latex.go +++ b/latex.go @@ -3,7 +3,7 @@ // Available at http://github.com/russross/blackfriday // // Copyright © 2011 Russ Ross . -// 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") diff --git a/markdown.go b/markdown.go index 135210b..0268010 100644 --- a/markdown.go +++ b/markdown.go @@ -3,7 +3,7 @@ // Available at http://github.com/russross/blackfriday // // Copyright © 2011 Russ Ross . -// 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 ( diff --git a/smartypants.go b/smartypants.go index bbd2b6d..63a69d8 100644 --- a/smartypants.go +++ b/smartypants.go @@ -3,7 +3,7 @@ // Available at http://github.com/russross/blackfriday // // Copyright © 2011 Russ Ross . -// Licensed under the Simplified BSD License. +// Distributed under the Simplified BSD License. // See README.md for details. // diff --git a/upskirtref_test.go b/upskirtref_test.go index 5a47f4f..4790bfd 100644 --- a/upskirtref_test.go +++ b/upskirtref_test.go @@ -3,7 +3,7 @@ // Available at http://github.com/russross/blackfriday // // Copyright © 2011 Russ Ross . -// Licensed under the Simplified BSD License. +// Distributed under the Simplified BSD License. // See README.md for details. //