From 0b697962488f48c6035509a15ce6ff5f8f114039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytautas=20=C5=A0altenis?= Date: Fri, 1 Apr 2016 15:37:21 +0300 Subject: [PATCH] Go style: more Html -> HTML renames --- block_test.go | 10 +++++----- html.go | 30 +++++++++++++++--------------- inline_test.go | 50 +++++++++++++++++++++++++------------------------- latex.go | 4 ++-- markdown.go | 4 ++-- ref_test.go | 2 +- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/block_test.go b/block_test.go index 2f1616c..6aa673b 100644 --- a/block_test.go +++ b/block_test.go @@ -23,13 +23,13 @@ func runMarkdownBlockWithRenderer(input string, extensions Extensions, renderer } 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 @@ func TestPrefixHeaderIdExtensionWithPrefixAndSuffix(t *testing.T) { "

Nested header

\n\n\n", } - parameters := HtmlRendererParameters{ + parameters := HTMLRendererParameters{ HeaderIDPrefix: "PRE:", HeaderIDSuffix: ":POST", } @@ -406,7 +406,7 @@ func TestPrefixAutoHeaderIdExtensionWithPrefixAndSuffix(t *testing.T) { "

Header

\n\n

Header 1

\n\n

Header

\n\n

Header

\n", } - parameters := HtmlRendererParameters{ + parameters := HTMLRendererParameters{ HeaderIDPrefix: "PRE:", HeaderIDSuffix: ":POST", } diff --git a/html.go b/html.go index 296078f..e17d58f 100644 --- a/html.go +++ b/html.go @@ -68,7 +68,7 @@ var ( 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 @@ type HtmlRendererParameters struct { // 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 @@ type HTML struct { // 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 @@ const ( 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 @@ func HtmlRendererWithParameters(flags HTMLFlags, extensions Extensions, title st renderParameters.FootnoteReturnLinkContents = `[return]` } - var writer HtmlWriter + var writer HTMLWriter return &HTML{ flags: flags, extensions: extensions, diff --git a/inline_test.go b/inline_test.go index c6f5074..037abf4 100644 --- a/inline_test.go +++ b/inline_test.go @@ -20,44 +20,44 @@ import ( "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 @@ func TestReferenceOverride(t *testing.T) { }, true } return nil, false - }}, 0, HtmlRendererParameters{}) + }}, 0, HTMLRendererParameters{}) } func TestStrong(t *testing.T) { @@ -426,7 +426,7 @@ func TestLineBreak(t *testing.T) { } doTestsInlineParam(t, tests, Options{ Extensions: BackslashLineBreak}, - 0, HtmlRendererParameters{}) + 0, HTMLRendererParameters{}) } func TestInlineLink(t *testing.T) { @@ -567,7 +567,7 @@ func TestRelAttrLink(t *testing.T) { "

foo

\n", } doTestsInlineParam(t, nofollowTests, Options{}, Safelink|NofollowLinks, - HtmlRendererParameters{}) + HTMLRendererParameters{}) var noreferrerTests = []string{ "[foo](http://bar.com/foo/)\n", @@ -577,7 +577,7 @@ func TestRelAttrLink(t *testing.T) { "

foo

\n", } doTestsInlineParam(t, noreferrerTests, Options{}, Safelink|NoreferrerLinks, - HtmlRendererParameters{}) + HTMLRendererParameters{}) var nofollownoreferrerTests = []string{ "[foo](http://bar.com/foo/)\n", @@ -587,7 +587,7 @@ func TestRelAttrLink(t *testing.T) { "

foo

\n", } doTestsInlineParam(t, nofollownoreferrerTests, Options{}, Safelink|NofollowLinks|NoreferrerLinks, - HtmlRendererParameters{}) + HTMLRendererParameters{}) } func TestHrefTargetBlank(t *testing.T) { @@ -614,7 +614,7 @@ func TestHrefTargetBlank(t *testing.T) { "[foo](http://example.com)\n", "

foo

\n", } - doTestsInlineParam(t, tests, Options{}, Safelink|HrefTargetBlank, HtmlRendererParameters{}) + doTestsInlineParam(t, tests, Options{}, Safelink|HrefTargetBlank, HTMLRendererParameters{}) } func TestSafeInlineLink(t *testing.T) { @@ -1002,7 +1002,7 @@ what happens here } 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 @@ func TestFootnotesWithParameters(t *testing.T) { tests[i] = test } - params := HtmlRendererParameters{ + params := HTMLRendererParameters{ FootnoteAnchorPrefix: prefix, FootnoteReturnLinkContents: returnText, } @@ -1055,7 +1055,7 @@ func TestNestedFootnotes(t *testing.T) { `, } doTestsInlineParam(t, tests, Options{Extensions: Footnotes}, 0, - HtmlRendererParameters{}) + HTMLRendererParameters{}) } func TestInlineComments(t *testing.T) { @@ -1084,7 +1084,7 @@ func TestInlineComments(t *testing.T) { "blahblah\n\nrhubarb\n", "

blahblah\n\nrhubarb

\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 @@ func TestSmartDoubleQuotes(t *testing.T) { "two pair of \"some\" quoted \"text\".\n", "

two pair of “some” quoted “text”.

\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 @@ func TestSmartAngledDoubleQuotes(t *testing.T) { "two pair of \"some\" quoted \"text\".\n", "

two pair of «some» quoted «text».

\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 @@ func TestSmartFractions(t *testing.T) { "1/2/2015, 1/4/2015, 3/4/2015; 2015/1/2, 2015/1/4, 2015/3/4.\n", "

1/2/2015, 1/4/2015, 3/4/2015; 2015/1/2, 2015/1/4, 2015/3/4.

\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 @@ func TestSmartFractions(t *testing.T) { "1/2/2015, 1/4/2015, 3/4/2015; 2015/1/2, 2015/1/4, 2015/3/4.\n", "

1/2/2015, 1/4/2015, 3/4/2015; 2015/1/2, 2015/1/4, 2015/3/4.

\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 @@ func TestDisableSmartDashes(t *testing.T) { "

foo -- bar

\n", "foo --- bar\n", "

foo --- bar

\n", - }, Options{}, 0, HtmlRendererParameters{}) + }, Options{}, 0, HTMLRendererParameters{}) doTestsInlineParam(t, []string{ "foo - bar\n", "

foo – bar

\n", @@ -1145,7 +1145,7 @@ func TestDisableSmartDashes(t *testing.T) { "

foo — bar

\n", "foo --- bar\n", "

foo —– bar

\n", - }, Options{Extensions: Smartypants | SmartypantsDashes}, 0, HtmlRendererParameters{}) + }, Options{Extensions: Smartypants | SmartypantsDashes}, 0, HTMLRendererParameters{}) doTestsInlineParam(t, []string{ "foo - bar\n", "

foo - bar

\n", @@ -1154,7 +1154,7 @@ func TestDisableSmartDashes(t *testing.T) { "foo --- bar\n", "

foo — bar

\n", }, Options{Extensions: Smartypants | SmartypantsLatexDashes | SmartypantsDashes}, 0, - HtmlRendererParameters{}) + HTMLRendererParameters{}) doTestsInlineParam(t, []string{ "foo - bar\n", "

foo - bar

\n", @@ -1164,5 +1164,5 @@ func TestDisableSmartDashes(t *testing.T) { "

foo --- bar

\n", }, Options{Extensions: Smartypants | SmartypantsLatexDashes}, 0, - HtmlRendererParameters{}) + HTMLRendererParameters{}) } diff --git a/latex.go b/latex.go index 5b32704..d059fa1 100644 --- a/latex.go +++ b/latex.go @@ -21,7 +21,7 @@ import "bytes" // // 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 @@ type Latex struct { // 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, } diff --git a/markdown.go b/markdown.go index ac446de..54c667f 100644 --- a/markdown.go +++ b/markdown.go @@ -344,7 +344,7 @@ type Options struct { 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 @@ func MarkdownBasic(input []byte) []byte { // * 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) } diff --git a/ref_test.go b/ref_test.go index 85f6903..8902bdc 100644 --- a/ref_test.go +++ b/ref_test.go @@ -20,7 +20,7 @@ import ( ) func runMarkdownReference(input string, flag Extensions) string { - renderer := HtmlRenderer(0, flag, "", "") + renderer := HTMLRenderer(0, flag, "", "") return string(Markdown([]byte(input), renderer, flag)) }