all repos — grayfriday @ 0b697962488f48c6035509a15ce6ff5f8f114039

blackfriday fork with a few changes

Go style: more Html -> HTML renames
Vytautas Ĺ altenis vytas@rtfb.lt
Fri, 01 Apr 2016 15:37:21 +0300
commit

0b697962488f48c6035509a15ce6ff5f8f114039

parent

02a5ce37ff682cb5a979aa7bd6e82a23b9ea8071

6 files changed, 50 insertions(+), 50 deletions(-)

jump to
M block_test.goblock_test.go

@@ -23,13 +23,13 @@ return string(Markdown([]byte(input), renderer, extensions))

} func runMarkdownBlock(input string, extensions Extensions) string { - renderer := HtmlRenderer(UseXHTML, extensions, "", "") + renderer := HTMLRenderer(UseXHTML, extensions, "", "") return runMarkdownBlockWithRenderer(input, extensions, renderer) } -func runnerWithRendererParameters(parameters HtmlRendererParameters) func(string, Extensions) string { +func runnerWithRendererParameters(parameters HTMLRendererParameters) func(string, Extensions) string { return func(input string, extensions Extensions) string { - renderer := HtmlRendererWithParameters(UseXHTML, extensions, "", "", parameters) + renderer := HTMLRendererWithParameters(UseXHTML, extensions, "", "", parameters) return runMarkdownBlockWithRenderer(input, extensions, renderer) } }

@@ -298,7 +298,7 @@ "<ul>\n<li><p>List</p>\n\n<ul>\n<li><p>Nested list</p>\n\n" +

"<h1 id=\"PRE:someid:POST\">Nested header</h1></li>\n</ul></li>\n</ul>\n", } - parameters := HtmlRendererParameters{ + parameters := HTMLRendererParameters{ HeaderIDPrefix: "PRE:", HeaderIDSuffix: ":POST", }

@@ -406,7 +406,7 @@ "# Header\n\n# Header 1\n\n# Header\n\n# Header",

"<h1 id=\"PRE:header:POST\">Header</h1>\n\n<h1 id=\"PRE:header-1:POST\">Header 1</h1>\n\n<h1 id=\"PRE:header-1-1:POST\">Header</h1>\n\n<h1 id=\"PRE:header-1-2:POST\">Header</h1>\n", } - parameters := HtmlRendererParameters{ + parameters := HTMLRendererParameters{ HeaderIDPrefix: "PRE:", HeaderIDSuffix: ":POST", }
M html.gohtml.go

@@ -68,7 +68,7 @@ htmlEntity = regexp.MustCompile(`&[a-z]{2,5};`)

reHtmlTag = regexp.MustCompile("(?i)^" + HTMLTag) ) -type HtmlRendererParameters struct { +type HTMLRendererParameters struct { // Prepend this text to each relative URL. AbsolutePrefix string // Add this text to each footnote anchor, to ensure uniqueness.

@@ -86,14 +86,14 @@ }

// HTML is a type that implements the Renderer interface for HTML output. // -// Do not create this directly, instead use the HtmlRenderer function. +// Do not create this directly, instead use the HTMLRenderer function. type HTML struct { flags HTMLFlags closeTag string // how to end singleton tags: either " />" or ">" title string // document title css string // optional css file url (used with HTML_COMPLETE_PAGE) - parameters HtmlRendererParameters + parameters HTMLRendererParameters // table of contents data tocMarker int

@@ -104,7 +104,7 @@

// Track header IDs to prevent ID collision in a single generation. headerIDs map[string]int - w HtmlWriter + w HTMLWriter lastOutputLen int disableTags int

@@ -116,36 +116,36 @@ xhtmlClose = " />"

htmlClose = ">" ) -// HtmlRenderer creates and configures an HTML object, which +// HTMLRenderer creates and configures an HTML object, which // satisfies the Renderer interface. // // flags is a set of HTMLFlags ORed together. // title is the title of the document, and css is a URL for the document's // stylesheet. // title and css are only used when HTML_COMPLETE_PAGE is selected. -func HtmlRenderer(flags HTMLFlags, extensions Extensions, title string, css string) Renderer { - return HtmlRendererWithParameters(flags, extensions, title, css, HtmlRendererParameters{}) +func HTMLRenderer(flags HTMLFlags, extensions Extensions, title string, css string) Renderer { + return HTMLRendererWithParameters(flags, extensions, title, css, HTMLRendererParameters{}) } -type HtmlWriter struct { +type HTMLWriter struct { output bytes.Buffer } -func (w *HtmlWriter) Write(p []byte) (n int, err error) { +func (w *HTMLWriter) Write(p []byte) (n int, err error) { return w.output.Write(p) } -func (w *HtmlWriter) WriteString(s string) (n int, err error) { +func (w *HTMLWriter) WriteString(s string) (n int, err error) { return w.output.WriteString(s) } -func (w *HtmlWriter) WriteByte(b byte) error { +func (w *HTMLWriter) WriteByte(b byte) error { return w.output.WriteByte(b) } // Writes out a newline if the output is not pristine. Used at the beginning of // every rendering func -func (w *HtmlWriter) Newline() { +func (w *HTMLWriter) Newline() { w.WriteByte('\n') }

@@ -153,8 +153,8 @@ func (r *HTML) Write(b []byte) (int, error) {

return r.w.Write(b) } -func HtmlRendererWithParameters(flags HTMLFlags, extensions Extensions, title string, - css string, renderParameters HtmlRendererParameters) Renderer { +func HTMLRendererWithParameters(flags HTMLFlags, extensions Extensions, title string, + css string, renderParameters HTMLRendererParameters) Renderer { // configure the rendering engine closeTag := htmlClose if flags&UseXHTML != 0 {

@@ -165,7 +165,7 @@ if renderParameters.FootnoteReturnLinkContents == "" {

renderParameters.FootnoteReturnLinkContents = `<sup>[return]</sup>` } - var writer HtmlWriter + var writer HTMLWriter return &HTML{ flags: flags, extensions: extensions,
M inline_test.goinline_test.go

@@ -20,44 +20,44 @@

"strings" ) -func runMarkdownInline(input string, opts Options, htmlFlags HTMLFlags, params HtmlRendererParameters) string { +func runMarkdownInline(input string, opts Options, htmlFlags HTMLFlags, params HTMLRendererParameters) string { opts.Extensions |= Autolink opts.Extensions |= Strikethrough htmlFlags |= UseXHTML - renderer := HtmlRendererWithParameters(htmlFlags, opts.Extensions, "", "", params) + renderer := HTMLRendererWithParameters(htmlFlags, opts.Extensions, "", "", params) return string(MarkdownOptions([]byte(input), renderer, opts)) } func doTestsInline(t *testing.T, tests []string) { - doTestsInlineParam(t, tests, Options{}, 0, HtmlRendererParameters{}) + doTestsInlineParam(t, tests, Options{}, 0, HTMLRendererParameters{}) } func doLinkTestsInline(t *testing.T, tests []string) { doTestsInline(t, tests) prefix := "http://localhost" - params := HtmlRendererParameters{AbsolutePrefix: prefix} + params := HTMLRendererParameters{AbsolutePrefix: prefix} transformTests := transformLinks(tests, prefix) doTestsInlineParam(t, transformTests, Options{}, 0, params) doTestsInlineParam(t, transformTests, Options{}, CommonHtmlFlags, params) } func doSafeTestsInline(t *testing.T, tests []string) { - doTestsInlineParam(t, tests, Options{}, Safelink, HtmlRendererParameters{}) + doTestsInlineParam(t, tests, Options{}, Safelink, HTMLRendererParameters{}) // All the links in this test should not have the prefix appended, so // just rerun it with different parameters and the same expectations. prefix := "http://localhost" - params := HtmlRendererParameters{AbsolutePrefix: prefix} + params := HTMLRendererParameters{AbsolutePrefix: prefix} transformTests := transformLinks(tests, prefix) doTestsInlineParam(t, transformTests, Options{}, Safelink, params) } func doTestsInlineParam(t *testing.T, tests []string, opts Options, htmlFlags HTMLFlags, - params HtmlRendererParameters) { + params HTMLRendererParameters) { // catch and report panics var candidate string /*

@@ -214,7 +214,7 @@ Text: "Moo",

}, true } return nil, false - }}, 0, HtmlRendererParameters{}) + }}, 0, HTMLRendererParameters{}) } func TestStrong(t *testing.T) {

@@ -426,7 +426,7 @@ "<p>this has an<br />\nextra space</p>\n",

} doTestsInlineParam(t, tests, Options{ Extensions: BackslashLineBreak}, - 0, HtmlRendererParameters{}) + 0, HTMLRendererParameters{}) } func TestInlineLink(t *testing.T) {

@@ -567,7 +567,7 @@ "[foo](../bar)\n",

"<p><a href=\"../bar\">foo</a></p>\n", } doTestsInlineParam(t, nofollowTests, Options{}, Safelink|NofollowLinks, - HtmlRendererParameters{}) + HTMLRendererParameters{}) var noreferrerTests = []string{ "[foo](http://bar.com/foo/)\n",

@@ -577,7 +577,7 @@ "[foo](/bar/)\n",

"<p><a href=\"/bar/\">foo</a></p>\n", } doTestsInlineParam(t, noreferrerTests, Options{}, Safelink|NoreferrerLinks, - HtmlRendererParameters{}) + HTMLRendererParameters{}) var nofollownoreferrerTests = []string{ "[foo](http://bar.com/foo/)\n",

@@ -587,7 +587,7 @@ "[foo](/bar/)\n",

"<p><a href=\"/bar/\">foo</a></p>\n", } doTestsInlineParam(t, nofollownoreferrerTests, Options{}, Safelink|NofollowLinks|NoreferrerLinks, - HtmlRendererParameters{}) + HTMLRendererParameters{}) } func TestHrefTargetBlank(t *testing.T) {

@@ -614,7 +614,7 @@

"[foo](http://example.com)\n", "<p><a href=\"http://example.com\" target=\"_blank\">foo</a></p>\n", } - doTestsInlineParam(t, tests, Options{}, Safelink|HrefTargetBlank, HtmlRendererParameters{}) + doTestsInlineParam(t, tests, Options{}, Safelink|HrefTargetBlank, HTMLRendererParameters{}) } func TestSafeInlineLink(t *testing.T) {

@@ -1002,7 +1002,7 @@ `,

} func TestFootnotes(t *testing.T) { - doTestsInlineParam(t, footnoteTests, Options{Extensions: Footnotes}, 0, HtmlRendererParameters{}) + doTestsInlineParam(t, footnoteTests, Options{Extensions: Footnotes}, 0, HTMLRendererParameters{}) } func TestFootnotesWithParameters(t *testing.T) {

@@ -1022,7 +1022,7 @@ }

tests[i] = test } - params := HtmlRendererParameters{ + params := HTMLRendererParameters{ FootnoteAnchorPrefix: prefix, FootnoteReturnLinkContents: returnText, }

@@ -1055,7 +1055,7 @@ </div>

`, } doTestsInlineParam(t, tests, Options{Extensions: Footnotes}, 0, - HtmlRendererParameters{}) + HTMLRendererParameters{}) } func TestInlineComments(t *testing.T) {

@@ -1084,7 +1084,7 @@

"blahblah\n<!--- foo -->\nrhubarb\n", "<p>blahblah\n<!--- foo -->\nrhubarb</p>\n", } - doTestsInlineParam(t, tests, Options{Extensions: Smartypants | SmartypantsDashes}, 0, HtmlRendererParameters{}) + doTestsInlineParam(t, tests, Options{Extensions: Smartypants | SmartypantsDashes}, 0, HTMLRendererParameters{}) } func TestSmartDoubleQuotes(t *testing.T) {

@@ -1096,7 +1096,7 @@ "<p>this &ldquo; single double</p>\n",

"two pair of \"some\" quoted \"text\".\n", "<p>two pair of &ldquo;some&rdquo; quoted &ldquo;text&rdquo;.</p>\n"} - doTestsInlineParam(t, tests, Options{Extensions: Smartypants}, 0, HtmlRendererParameters{}) + doTestsInlineParam(t, tests, Options{Extensions: Smartypants}, 0, HTMLRendererParameters{}) } func TestSmartAngledDoubleQuotes(t *testing.T) {

@@ -1108,7 +1108,7 @@ "<p>this &laquo; single double</p>\n",

"two pair of \"some\" quoted \"text\".\n", "<p>two pair of &laquo;some&raquo; quoted &laquo;text&raquo;.</p>\n"} - doTestsInlineParam(t, tests, Options{Extensions: Smartypants | SmartypantsAngledQuotes}, 0, HtmlRendererParameters{}) + doTestsInlineParam(t, tests, Options{Extensions: Smartypants | SmartypantsAngledQuotes}, 0, HTMLRendererParameters{}) } func TestSmartFractions(t *testing.T) {

@@ -1118,7 +1118,7 @@ "<p>&frac12;, &frac14; and &frac34;; &frac14;th and &frac34;ths</p>\n",

"1/2/2015, 1/4/2015, 3/4/2015; 2015/1/2, 2015/1/4, 2015/3/4.\n", "<p>1/2/2015, 1/4/2015, 3/4/2015; 2015/1/2, 2015/1/4, 2015/3/4.</p>\n"} - doTestsInlineParam(t, tests, Options{Extensions: Smartypants}, 0, HtmlRendererParameters{}) + doTestsInlineParam(t, tests, Options{Extensions: Smartypants}, 0, HTMLRendererParameters{}) tests = []string{ "1/2, 2/3, 81/100 and 1000000/1048576.\n",

@@ -1126,7 +1126,7 @@ "<p><sup>1</sup>&frasl;<sub>2</sub>, <sup>2</sup>&frasl;<sub>3</sub>, <sup>81</sup>&frasl;<sub>100</sub> and <sup>1000000</sup>&frasl;<sub>1048576</sub>.</p>\n",

"1/2/2015, 1/4/2015, 3/4/2015; 2015/1/2, 2015/1/4, 2015/3/4.\n", "<p>1/2/2015, 1/4/2015, 3/4/2015; 2015/1/2, 2015/1/4, 2015/3/4.</p>\n"} - doTestsInlineParam(t, tests, Options{Extensions: Smartypants | SmartypantsFractions}, 0, HtmlRendererParameters{}) + doTestsInlineParam(t, tests, Options{Extensions: Smartypants | SmartypantsFractions}, 0, HTMLRendererParameters{}) } func TestDisableSmartDashes(t *testing.T) {

@@ -1137,7 +1137,7 @@ "foo -- bar\n",

"<p>foo -- bar</p>\n", "foo --- bar\n", "<p>foo --- bar</p>\n", - }, Options{}, 0, HtmlRendererParameters{}) + }, Options{}, 0, HTMLRendererParameters{}) doTestsInlineParam(t, []string{ "foo - bar\n", "<p>foo &ndash; bar</p>\n",

@@ -1145,7 +1145,7 @@ "foo -- bar\n",

"<p>foo &mdash; bar</p>\n", "foo --- bar\n", "<p>foo &mdash;&ndash; bar</p>\n", - }, Options{Extensions: Smartypants | SmartypantsDashes}, 0, HtmlRendererParameters{}) + }, Options{Extensions: Smartypants | SmartypantsDashes}, 0, HTMLRendererParameters{}) doTestsInlineParam(t, []string{ "foo - bar\n", "<p>foo - bar</p>\n",

@@ -1154,7 +1154,7 @@ "<p>foo &ndash; bar</p>\n",

"foo --- bar\n", "<p>foo &mdash; bar</p>\n", }, Options{Extensions: Smartypants | SmartypantsLatexDashes | SmartypantsDashes}, 0, - HtmlRendererParameters{}) + HTMLRendererParameters{}) doTestsInlineParam(t, []string{ "foo - bar\n", "<p>foo - bar</p>\n",

@@ -1164,5 +1164,5 @@ "foo --- bar\n",

"<p>foo --- bar</p>\n", }, Options{Extensions: Smartypants | SmartypantsLatexDashes}, 0, - HtmlRendererParameters{}) + HTMLRendererParameters{}) }
M latex.golatex.go

@@ -21,7 +21,7 @@ // Latex is a type that implements the Renderer interface for LaTeX output.

// // Do not create this directly, instead use the LatexRenderer function. type Latex struct { - w HtmlWriter + w HTMLWriter } // LatexRenderer creates and configures a Latex object, which

@@ -30,7 +30,7 @@ //

// flags is a set of LATEX_* options ORed together (currently no such options // are defined). func LatexRenderer(flags int) Renderer { - var writer HtmlWriter + var writer HTMLWriter return &Latex{ w: writer, }
M markdown.gomarkdown.go

@@ -344,7 +344,7 @@ // It processes markdown input with no extensions enabled.

func MarkdownBasic(input []byte) []byte { // set up the HTML renderer htmlFlags := UseXHTML - renderer := HtmlRenderer(htmlFlags, CommonExtensions, "", "") + renderer := HTMLRenderer(htmlFlags, CommonExtensions, "", "") // set up the parser return MarkdownOptions(input, renderer, Options{Extensions: 0})

@@ -371,7 +371,7 @@ //

// * Custom Header IDs func MarkdownCommon(input []byte) []byte { // set up the HTML renderer - renderer := HtmlRenderer(CommonHtmlFlags, CommonExtensions, "", "") + renderer := HTMLRenderer(CommonHtmlFlags, CommonExtensions, "", "") return MarkdownOptions(input, renderer, DefaultOptions) }
M ref_test.goref_test.go

@@ -20,7 +20,7 @@ "testing"

) func runMarkdownReference(input string, flag Extensions) string { - renderer := HtmlRenderer(0, flag, "", "") + renderer := HTMLRenderer(0, flag, "", "") return string(Markdown([]byte(input), renderer, flag)) }