mirror of
https://github.com/danog/blackfriday.git
synced 2025-01-23 05:41:27 +01:00
Go style: more Html -> HTML renames
This commit is contained in:
parent
02a5ce37ff
commit
0b69796248
@ -23,13 +23,13 @@ func runMarkdownBlockWithRenderer(input string, extensions Extensions, renderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runMarkdownBlock(input string, extensions Extensions) string {
|
func runMarkdownBlock(input string, extensions Extensions) string {
|
||||||
renderer := HtmlRenderer(UseXHTML, extensions, "", "")
|
renderer := HTMLRenderer(UseXHTML, extensions, "", "")
|
||||||
return runMarkdownBlockWithRenderer(input, extensions, renderer)
|
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 {
|
return func(input string, extensions Extensions) string {
|
||||||
renderer := HtmlRendererWithParameters(UseXHTML, extensions, "", "", parameters)
|
renderer := HTMLRendererWithParameters(UseXHTML, extensions, "", "", parameters)
|
||||||
return runMarkdownBlockWithRenderer(input, extensions, renderer)
|
return runMarkdownBlockWithRenderer(input, extensions, renderer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,7 +298,7 @@ func TestPrefixHeaderIdExtensionWithPrefixAndSuffix(t *testing.T) {
|
|||||||
"<h1 id=\"PRE:someid:POST\">Nested header</h1></li>\n</ul></li>\n</ul>\n",
|
"<h1 id=\"PRE:someid:POST\">Nested header</h1></li>\n</ul></li>\n</ul>\n",
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters := HtmlRendererParameters{
|
parameters := HTMLRendererParameters{
|
||||||
HeaderIDPrefix: "PRE:",
|
HeaderIDPrefix: "PRE:",
|
||||||
HeaderIDSuffix: ":POST",
|
HeaderIDSuffix: ":POST",
|
||||||
}
|
}
|
||||||
@ -406,7 +406,7 @@ func TestPrefixAutoHeaderIdExtensionWithPrefixAndSuffix(t *testing.T) {
|
|||||||
"<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",
|
"<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:",
|
HeaderIDPrefix: "PRE:",
|
||||||
HeaderIDSuffix: ":POST",
|
HeaderIDSuffix: ":POST",
|
||||||
}
|
}
|
||||||
|
30
html.go
30
html.go
@ -68,7 +68,7 @@ var (
|
|||||||
reHtmlTag = regexp.MustCompile("(?i)^" + HTMLTag)
|
reHtmlTag = regexp.MustCompile("(?i)^" + HTMLTag)
|
||||||
)
|
)
|
||||||
|
|
||||||
type HtmlRendererParameters struct {
|
type HTMLRendererParameters struct {
|
||||||
// Prepend this text to each relative URL.
|
// Prepend this text to each relative URL.
|
||||||
AbsolutePrefix string
|
AbsolutePrefix string
|
||||||
// Add this text to each footnote anchor, to ensure uniqueness.
|
// 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.
|
// 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 {
|
type HTML struct {
|
||||||
flags HTMLFlags
|
flags HTMLFlags
|
||||||
closeTag string // how to end singleton tags: either " />" or ">"
|
closeTag string // how to end singleton tags: either " />" or ">"
|
||||||
title string // document title
|
title string // document title
|
||||||
css string // optional css file url (used with HTML_COMPLETE_PAGE)
|
css string // optional css file url (used with HTML_COMPLETE_PAGE)
|
||||||
|
|
||||||
parameters HtmlRendererParameters
|
parameters HTMLRendererParameters
|
||||||
|
|
||||||
// table of contents data
|
// table of contents data
|
||||||
tocMarker int
|
tocMarker int
|
||||||
@ -104,7 +104,7 @@ type HTML struct {
|
|||||||
// Track header IDs to prevent ID collision in a single generation.
|
// Track header IDs to prevent ID collision in a single generation.
|
||||||
headerIDs map[string]int
|
headerIDs map[string]int
|
||||||
|
|
||||||
w HtmlWriter
|
w HTMLWriter
|
||||||
lastOutputLen int
|
lastOutputLen int
|
||||||
disableTags int
|
disableTags int
|
||||||
|
|
||||||
@ -116,36 +116,36 @@ const (
|
|||||||
htmlClose = ">"
|
htmlClose = ">"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HtmlRenderer creates and configures an HTML object, which
|
// HTMLRenderer creates and configures an HTML object, which
|
||||||
// satisfies the Renderer interface.
|
// satisfies the Renderer interface.
|
||||||
//
|
//
|
||||||
// flags is a set of HTMLFlags ORed together.
|
// flags is a set of HTMLFlags ORed together.
|
||||||
// title is the title of the document, and css is a URL for the document's
|
// title is the title of the document, and css is a URL for the document's
|
||||||
// stylesheet.
|
// stylesheet.
|
||||||
// title and css are only used when HTML_COMPLETE_PAGE is selected.
|
// title and css are only used when HTML_COMPLETE_PAGE is selected.
|
||||||
func HtmlRenderer(flags HTMLFlags, extensions Extensions, title string, css string) Renderer {
|
func HTMLRenderer(flags HTMLFlags, extensions Extensions, title string, css string) Renderer {
|
||||||
return HtmlRendererWithParameters(flags, extensions, title, css, HtmlRendererParameters{})
|
return HTMLRendererWithParameters(flags, extensions, title, css, HTMLRendererParameters{})
|
||||||
}
|
}
|
||||||
|
|
||||||
type HtmlWriter struct {
|
type HTMLWriter struct {
|
||||||
output bytes.Buffer
|
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)
|
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)
|
return w.output.WriteString(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *HtmlWriter) WriteByte(b byte) error {
|
func (w *HTMLWriter) WriteByte(b byte) error {
|
||||||
return w.output.WriteByte(b)
|
return w.output.WriteByte(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writes out a newline if the output is not pristine. Used at the beginning of
|
// Writes out a newline if the output is not pristine. Used at the beginning of
|
||||||
// every rendering func
|
// every rendering func
|
||||||
func (w *HtmlWriter) Newline() {
|
func (w *HTMLWriter) Newline() {
|
||||||
w.WriteByte('\n')
|
w.WriteByte('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,8 +153,8 @@ func (r *HTML) Write(b []byte) (int, error) {
|
|||||||
return r.w.Write(b)
|
return r.w.Write(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func HtmlRendererWithParameters(flags HTMLFlags, extensions Extensions, title string,
|
func HTMLRendererWithParameters(flags HTMLFlags, extensions Extensions, title string,
|
||||||
css string, renderParameters HtmlRendererParameters) Renderer {
|
css string, renderParameters HTMLRendererParameters) Renderer {
|
||||||
// configure the rendering engine
|
// configure the rendering engine
|
||||||
closeTag := htmlClose
|
closeTag := htmlClose
|
||||||
if flags&UseXHTML != 0 {
|
if flags&UseXHTML != 0 {
|
||||||
@ -165,7 +165,7 @@ func HtmlRendererWithParameters(flags HTMLFlags, extensions Extensions, title st
|
|||||||
renderParameters.FootnoteReturnLinkContents = `<sup>[return]</sup>`
|
renderParameters.FootnoteReturnLinkContents = `<sup>[return]</sup>`
|
||||||
}
|
}
|
||||||
|
|
||||||
var writer HtmlWriter
|
var writer HTMLWriter
|
||||||
return &HTML{
|
return &HTML{
|
||||||
flags: flags,
|
flags: flags,
|
||||||
extensions: extensions,
|
extensions: extensions,
|
||||||
|
@ -20,44 +20,44 @@ import (
|
|||||||
"strings"
|
"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 |= Autolink
|
||||||
opts.Extensions |= Strikethrough
|
opts.Extensions |= Strikethrough
|
||||||
|
|
||||||
htmlFlags |= UseXHTML
|
htmlFlags |= UseXHTML
|
||||||
|
|
||||||
renderer := HtmlRendererWithParameters(htmlFlags, opts.Extensions, "", "", params)
|
renderer := HTMLRendererWithParameters(htmlFlags, opts.Extensions, "", "", params)
|
||||||
|
|
||||||
return string(MarkdownOptions([]byte(input), renderer, opts))
|
return string(MarkdownOptions([]byte(input), renderer, opts))
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTestsInline(t *testing.T, tests []string) {
|
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) {
|
func doLinkTestsInline(t *testing.T, tests []string) {
|
||||||
doTestsInline(t, tests)
|
doTestsInline(t, tests)
|
||||||
|
|
||||||
prefix := "http://localhost"
|
prefix := "http://localhost"
|
||||||
params := HtmlRendererParameters{AbsolutePrefix: prefix}
|
params := HTMLRendererParameters{AbsolutePrefix: prefix}
|
||||||
transformTests := transformLinks(tests, prefix)
|
transformTests := transformLinks(tests, prefix)
|
||||||
doTestsInlineParam(t, transformTests, Options{}, 0, params)
|
doTestsInlineParam(t, transformTests, Options{}, 0, params)
|
||||||
doTestsInlineParam(t, transformTests, Options{}, CommonHtmlFlags, params)
|
doTestsInlineParam(t, transformTests, Options{}, CommonHtmlFlags, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
func doSafeTestsInline(t *testing.T, tests []string) {
|
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
|
// All the links in this test should not have the prefix appended, so
|
||||||
// just rerun it with different parameters and the same expectations.
|
// just rerun it with different parameters and the same expectations.
|
||||||
prefix := "http://localhost"
|
prefix := "http://localhost"
|
||||||
params := HtmlRendererParameters{AbsolutePrefix: prefix}
|
params := HTMLRendererParameters{AbsolutePrefix: prefix}
|
||||||
transformTests := transformLinks(tests, prefix)
|
transformTests := transformLinks(tests, prefix)
|
||||||
doTestsInlineParam(t, transformTests, Options{}, Safelink, params)
|
doTestsInlineParam(t, transformTests, Options{}, Safelink, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTestsInlineParam(t *testing.T, tests []string, opts Options, htmlFlags HTMLFlags,
|
func doTestsInlineParam(t *testing.T, tests []string, opts Options, htmlFlags HTMLFlags,
|
||||||
params HtmlRendererParameters) {
|
params HTMLRendererParameters) {
|
||||||
// catch and report panics
|
// catch and report panics
|
||||||
var candidate string
|
var candidate string
|
||||||
/*
|
/*
|
||||||
@ -214,7 +214,7 @@ func TestReferenceOverride(t *testing.T) {
|
|||||||
}, true
|
}, true
|
||||||
}
|
}
|
||||||
return nil, false
|
return nil, false
|
||||||
}}, 0, HtmlRendererParameters{})
|
}}, 0, HTMLRendererParameters{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStrong(t *testing.T) {
|
func TestStrong(t *testing.T) {
|
||||||
@ -426,7 +426,7 @@ func TestLineBreak(t *testing.T) {
|
|||||||
}
|
}
|
||||||
doTestsInlineParam(t, tests, Options{
|
doTestsInlineParam(t, tests, Options{
|
||||||
Extensions: BackslashLineBreak},
|
Extensions: BackslashLineBreak},
|
||||||
0, HtmlRendererParameters{})
|
0, HTMLRendererParameters{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInlineLink(t *testing.T) {
|
func TestInlineLink(t *testing.T) {
|
||||||
@ -567,7 +567,7 @@ func TestRelAttrLink(t *testing.T) {
|
|||||||
"<p><a href=\"../bar\">foo</a></p>\n",
|
"<p><a href=\"../bar\">foo</a></p>\n",
|
||||||
}
|
}
|
||||||
doTestsInlineParam(t, nofollowTests, Options{}, Safelink|NofollowLinks,
|
doTestsInlineParam(t, nofollowTests, Options{}, Safelink|NofollowLinks,
|
||||||
HtmlRendererParameters{})
|
HTMLRendererParameters{})
|
||||||
|
|
||||||
var noreferrerTests = []string{
|
var noreferrerTests = []string{
|
||||||
"[foo](http://bar.com/foo/)\n",
|
"[foo](http://bar.com/foo/)\n",
|
||||||
@ -577,7 +577,7 @@ func TestRelAttrLink(t *testing.T) {
|
|||||||
"<p><a href=\"/bar/\">foo</a></p>\n",
|
"<p><a href=\"/bar/\">foo</a></p>\n",
|
||||||
}
|
}
|
||||||
doTestsInlineParam(t, noreferrerTests, Options{}, Safelink|NoreferrerLinks,
|
doTestsInlineParam(t, noreferrerTests, Options{}, Safelink|NoreferrerLinks,
|
||||||
HtmlRendererParameters{})
|
HTMLRendererParameters{})
|
||||||
|
|
||||||
var nofollownoreferrerTests = []string{
|
var nofollownoreferrerTests = []string{
|
||||||
"[foo](http://bar.com/foo/)\n",
|
"[foo](http://bar.com/foo/)\n",
|
||||||
@ -587,7 +587,7 @@ func TestRelAttrLink(t *testing.T) {
|
|||||||
"<p><a href=\"/bar/\">foo</a></p>\n",
|
"<p><a href=\"/bar/\">foo</a></p>\n",
|
||||||
}
|
}
|
||||||
doTestsInlineParam(t, nofollownoreferrerTests, Options{}, Safelink|NofollowLinks|NoreferrerLinks,
|
doTestsInlineParam(t, nofollownoreferrerTests, Options{}, Safelink|NofollowLinks|NoreferrerLinks,
|
||||||
HtmlRendererParameters{})
|
HTMLRendererParameters{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHrefTargetBlank(t *testing.T) {
|
func TestHrefTargetBlank(t *testing.T) {
|
||||||
@ -614,7 +614,7 @@ func TestHrefTargetBlank(t *testing.T) {
|
|||||||
"[foo](http://example.com)\n",
|
"[foo](http://example.com)\n",
|
||||||
"<p><a href=\"http://example.com\" target=\"_blank\">foo</a></p>\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) {
|
func TestSafeInlineLink(t *testing.T) {
|
||||||
@ -1002,7 +1002,7 @@ what happens here
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFootnotes(t *testing.T) {
|
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) {
|
func TestFootnotesWithParameters(t *testing.T) {
|
||||||
@ -1022,7 +1022,7 @@ func TestFootnotesWithParameters(t *testing.T) {
|
|||||||
tests[i] = test
|
tests[i] = test
|
||||||
}
|
}
|
||||||
|
|
||||||
params := HtmlRendererParameters{
|
params := HTMLRendererParameters{
|
||||||
FootnoteAnchorPrefix: prefix,
|
FootnoteAnchorPrefix: prefix,
|
||||||
FootnoteReturnLinkContents: returnText,
|
FootnoteReturnLinkContents: returnText,
|
||||||
}
|
}
|
||||||
@ -1055,7 +1055,7 @@ func TestNestedFootnotes(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
doTestsInlineParam(t, tests, Options{Extensions: Footnotes}, 0,
|
doTestsInlineParam(t, tests, Options{Extensions: Footnotes}, 0,
|
||||||
HtmlRendererParameters{})
|
HTMLRendererParameters{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInlineComments(t *testing.T) {
|
func TestInlineComments(t *testing.T) {
|
||||||
@ -1084,7 +1084,7 @@ func TestInlineComments(t *testing.T) {
|
|||||||
"blahblah\n<!--- foo -->\nrhubarb\n",
|
"blahblah\n<!--- foo -->\nrhubarb\n",
|
||||||
"<p>blahblah\n<!--- foo -->\nrhubarb</p>\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) {
|
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",
|
||||||
"<p>two pair of “some” quoted “text”.</p>\n"}
|
"<p>two pair of “some” quoted “text”.</p>\n"}
|
||||||
|
|
||||||
doTestsInlineParam(t, tests, Options{Extensions: Smartypants}, 0, HtmlRendererParameters{})
|
doTestsInlineParam(t, tests, Options{Extensions: Smartypants}, 0, HTMLRendererParameters{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSmartAngledDoubleQuotes(t *testing.T) {
|
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",
|
||||||
"<p>two pair of «some» quoted «text».</p>\n"}
|
"<p>two pair of «some» quoted «text».</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) {
|
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",
|
||||||
"<p>1/2/2015, 1/4/2015, 3/4/2015; 2015/1/2, 2015/1/4, 2015/3/4.</p>\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{
|
tests = []string{
|
||||||
"1/2, 2/3, 81/100 and 1000000/1048576.\n",
|
"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",
|
||||||
"<p>1/2/2015, 1/4/2015, 3/4/2015; 2015/1/2, 2015/1/4, 2015/3/4.</p>\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) {
|
func TestDisableSmartDashes(t *testing.T) {
|
||||||
@ -1137,7 +1137,7 @@ func TestDisableSmartDashes(t *testing.T) {
|
|||||||
"<p>foo -- bar</p>\n",
|
"<p>foo -- bar</p>\n",
|
||||||
"foo --- bar\n",
|
"foo --- bar\n",
|
||||||
"<p>foo --- bar</p>\n",
|
"<p>foo --- bar</p>\n",
|
||||||
}, Options{}, 0, HtmlRendererParameters{})
|
}, Options{}, 0, HTMLRendererParameters{})
|
||||||
doTestsInlineParam(t, []string{
|
doTestsInlineParam(t, []string{
|
||||||
"foo - bar\n",
|
"foo - bar\n",
|
||||||
"<p>foo – bar</p>\n",
|
"<p>foo – bar</p>\n",
|
||||||
@ -1145,7 +1145,7 @@ func TestDisableSmartDashes(t *testing.T) {
|
|||||||
"<p>foo — bar</p>\n",
|
"<p>foo — bar</p>\n",
|
||||||
"foo --- bar\n",
|
"foo --- bar\n",
|
||||||
"<p>foo —– bar</p>\n",
|
"<p>foo —– bar</p>\n",
|
||||||
}, Options{Extensions: Smartypants | SmartypantsDashes}, 0, HtmlRendererParameters{})
|
}, Options{Extensions: Smartypants | SmartypantsDashes}, 0, HTMLRendererParameters{})
|
||||||
doTestsInlineParam(t, []string{
|
doTestsInlineParam(t, []string{
|
||||||
"foo - bar\n",
|
"foo - bar\n",
|
||||||
"<p>foo - bar</p>\n",
|
"<p>foo - bar</p>\n",
|
||||||
@ -1154,7 +1154,7 @@ func TestDisableSmartDashes(t *testing.T) {
|
|||||||
"foo --- bar\n",
|
"foo --- bar\n",
|
||||||
"<p>foo — bar</p>\n",
|
"<p>foo — bar</p>\n",
|
||||||
}, Options{Extensions: Smartypants | SmartypantsLatexDashes | SmartypantsDashes}, 0,
|
}, Options{Extensions: Smartypants | SmartypantsLatexDashes | SmartypantsDashes}, 0,
|
||||||
HtmlRendererParameters{})
|
HTMLRendererParameters{})
|
||||||
doTestsInlineParam(t, []string{
|
doTestsInlineParam(t, []string{
|
||||||
"foo - bar\n",
|
"foo - bar\n",
|
||||||
"<p>foo - bar</p>\n",
|
"<p>foo - bar</p>\n",
|
||||||
@ -1164,5 +1164,5 @@ func TestDisableSmartDashes(t *testing.T) {
|
|||||||
"<p>foo --- bar</p>\n",
|
"<p>foo --- bar</p>\n",
|
||||||
}, Options{Extensions: Smartypants | SmartypantsLatexDashes},
|
}, Options{Extensions: Smartypants | SmartypantsLatexDashes},
|
||||||
0,
|
0,
|
||||||
HtmlRendererParameters{})
|
HTMLRendererParameters{})
|
||||||
}
|
}
|
||||||
|
4
latex.go
4
latex.go
@ -21,7 +21,7 @@ import "bytes"
|
|||||||
//
|
//
|
||||||
// Do not create this directly, instead use the LatexRenderer function.
|
// Do not create this directly, instead use the LatexRenderer function.
|
||||||
type Latex struct {
|
type Latex struct {
|
||||||
w HtmlWriter
|
w HTMLWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
// LatexRenderer creates and configures a Latex object, which
|
// 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
|
// flags is a set of LATEX_* options ORed together (currently no such options
|
||||||
// are defined).
|
// are defined).
|
||||||
func LatexRenderer(flags int) Renderer {
|
func LatexRenderer(flags int) Renderer {
|
||||||
var writer HtmlWriter
|
var writer HTMLWriter
|
||||||
return &Latex{
|
return &Latex{
|
||||||
w: writer,
|
w: writer,
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,7 @@ type Options struct {
|
|||||||
func MarkdownBasic(input []byte) []byte {
|
func MarkdownBasic(input []byte) []byte {
|
||||||
// set up the HTML renderer
|
// set up the HTML renderer
|
||||||
htmlFlags := UseXHTML
|
htmlFlags := UseXHTML
|
||||||
renderer := HtmlRenderer(htmlFlags, CommonExtensions, "", "")
|
renderer := HTMLRenderer(htmlFlags, CommonExtensions, "", "")
|
||||||
|
|
||||||
// set up the parser
|
// set up the parser
|
||||||
return MarkdownOptions(input, renderer, Options{Extensions: 0})
|
return MarkdownOptions(input, renderer, Options{Extensions: 0})
|
||||||
@ -371,7 +371,7 @@ func MarkdownBasic(input []byte) []byte {
|
|||||||
// * Custom Header IDs
|
// * Custom Header IDs
|
||||||
func MarkdownCommon(input []byte) []byte {
|
func MarkdownCommon(input []byte) []byte {
|
||||||
// set up the HTML renderer
|
// set up the HTML renderer
|
||||||
renderer := HtmlRenderer(CommonHtmlFlags, CommonExtensions, "", "")
|
renderer := HTMLRenderer(CommonHtmlFlags, CommonExtensions, "", "")
|
||||||
return MarkdownOptions(input, renderer, DefaultOptions)
|
return MarkdownOptions(input, renderer, DefaultOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func runMarkdownReference(input string, flag Extensions) string {
|
func runMarkdownReference(input string, flag Extensions) string {
|
||||||
renderer := HtmlRenderer(0, flag, "", "")
|
renderer := HTMLRenderer(0, flag, "", "")
|
||||||
return string(Markdown([]byte(input), renderer, flag))
|
return string(Markdown([]byte(input), renderer, flag))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user