all repos — grayfriday @ fde2c60665de643152ebbfb4fc9e8b83da09cadf

blackfriday fork with a few changes

version number, few more options for command-line tool
Russ Ross russ@dixie.edu
Tue, 28 Jun 2011 11:30:10 -0600
commit

fde2c60665de643152ebbfb4fc9e8b83da09cadf

parent

84eeba25620390256a381fa34a6884b6041bbbf6

M README.mdREADME.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 @@

* 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 @@ * More unit testing

* 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
M block.goblock.go

@@ -3,7 +3,7 @@ // Blackfriday Markdown Processor

// 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. //
M block_test.goblock_test.go

@@ -3,7 +3,7 @@ // Blackfriday Markdown Processor

// 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. //
M example/main.goexample/main.go

@@ -3,7 +3,7 @@ // Blackfriday Markdown Processor

// 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 @@ )

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 @@ flag.BoolVar(&xhtml, "xhtml", true,

"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 @@ "Write cpu profile to a file")

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 @@ html_flags |= blackfriday.HTML_USE_XHTML

} 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 @@ fmt.Fprintln(out, "<html>")

} 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) }
M html.gohtml.go

@@ -3,7 +3,7 @@ // Blackfriday Markdown Processor

// 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. //
M inline.goinline.go

@@ -3,7 +3,7 @@ // Blackfriday Markdown Processor

// 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. //
M inline_test.goinline_test.go

@@ -3,7 +3,7 @@ // Blackfriday Markdown Processor

// 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. //
M latex.golatex.go

@@ -3,7 +3,7 @@ // Blackfriday Markdown Processor

// 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 @@ out.WriteString(" linkcolor=black,%\n")

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")
M markdown.gomarkdown.go

@@ -3,7 +3,7 @@ // Blackfriday Markdown Processor

// 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. //

@@ -19,6 +19,8 @@ import (

"bytes" "utf8" ) + +const VERSION = "0.5" // These are the supported markdown parsing extensions. // OR these values together to select multiple extensions.
M smartypants.gosmartypants.go

@@ -3,7 +3,7 @@ // Blackfriday Markdown Processor

// 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. //
M upskirtref_test.goupskirtref_test.go

@@ -3,7 +3,7 @@ // Blackfriday Markdown Processor

// 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. //