Merge pull request #324 from russross/move-toc-to-html Move TOC and OmitContents to HTML flags
Vytautas Ĺ altenis vytas@rtfb.lt
Wed, 07 Dec 2016 21:07:04 +0200
4 files changed,
17 insertions(+),
16 deletions(-)
M
block_test.go
→
block_test.go
@@ -1601,7 +1601,9 @@ // Trigger empty TOC
"#", "", } - doTestsBlock(t, tests, TOC) + doTestsParam(t, tests, TestParams{ + HTMLFlags: UseXHTML | TOC, + }) } func TestOmitContents(t *testing.T) {@@ -1625,9 +1627,13 @@ // Make sure OmitContents omits even with no TOC
"#\n\nfoo", "", } - doTestsBlock(t, tests, TOC|OmitContents) + doTestsParam(t, tests, TestParams{ + HTMLFlags: UseXHTML | TOC | OmitContents, + }) // Now run again: make sure OmitContents implies TOC - doTestsBlock(t, tests, OmitContents) + doTestsParam(t, tests, TestParams{ + HTMLFlags: UseXHTML | OmitContents, + }) } func TestCompletePage(t *testing.T) {
M
helpers_test.go
→
helpers_test.go
@@ -44,7 +44,6 @@ }
func runMarkdown(input string, params TestParams) string { params.HTMLRendererParameters.Flags = params.HTMLFlags - params.HTMLRendererParameters.Extensions = params.Options.Extensions renderer := NewHTMLRenderer(params.HTMLRendererParameters) return string(Markdown([]byte(input), renderer, params.Options)) }@@ -54,8 +53,7 @@ func doTests(t *testing.T, tests []string) {
doTestsParam(t, tests, TestParams{ Options: DefaultOptions, HTMLRendererParameters: HTMLRendererParameters{ - Flags: CommonHTMLFlags, - Extensions: CommonExtensions, + Flags: CommonHTMLFlags, }, }) }
M
html.go
→
html.go
@@ -45,6 +45,8 @@ SmartypantsFractions // Enable smart fractions (with Smartypants)
SmartypantsDashes // Enable smart dashes (with Smartypants) SmartypantsLatexDashes // Enable LaTeX-style dashes (with Smartypants) SmartypantsAngledQuotes // Enable angled double quotes (with Smartypants) for double quotes rendering + TOC // Generate a table of contents + OmitContents // Skip the main contents (for a standalone table of contents) TagName = "[A-Za-z][A-Za-z0-9-]*" AttributeName = "[a-zA-Z_:][a-zA-Z0-9:._-]*"@@ -89,8 +91,7 @@ Title string // Document title (used if CompletePage is set)
CSS string // Optional CSS file URL (used if CompletePage is set) Icon string // Optional icon file URL (used if CompletePage is set) - Flags HTMLFlags // Flags allow customizing this renderer's behavior - Extensions Extensions // Extensions give Smartypants and HTML renderer access to Blackfriday's global extensions + Flags HTMLFlags // Flags allow customizing this renderer's behavior } // HTMLRenderer is a type that implements the Renderer interface for HTML output.@@ -821,9 +822,9 @@ //println("render_Blackfriday")
//dump(ast) var buff bytes.Buffer r.writeDocumentHeader(&buff) - if r.Extensions&TOC != 0 || r.Extensions&OmitContents != 0 { + if r.Flags&TOC != 0 || r.Flags&OmitContents != 0 { r.writeTOC(&buff, ast) - if r.Extensions&OmitContents != 0 { + if r.Flags&OmitContents != 0 { return buff.Bytes() } }
M
markdown.go
→
markdown.go
@@ -46,8 +46,6 @@ Titleblock // Titleblock ala pandoc
AutoHeaderIDs // Create the header ID from the text BackslashLineBreak // Translate trailing backslashes into line breaks DefinitionLists // Render definition lists - TOC // Generate a table of contents - OmitContents // Skip the main contents (for a standalone table of contents) CommonHTMLFlags HTMLFlags = UseXHTML | Smartypants | SmartypantsFractions | SmartypantsDashes | SmartypantsLatexDashes@@ -290,8 +288,7 @@ // It processes markdown input with no extensions enabled.
func MarkdownBasic(input []byte) []byte { // set up the HTML renderer renderer := NewHTMLRenderer(HTMLRendererParameters{ - Flags: UseXHTML, - Extensions: CommonExtensions, + Flags: UseXHTML, }) // set up the parser@@ -319,8 +316,7 @@ // * Custom Header IDs
func MarkdownCommon(input []byte) []byte { // set up the HTML renderer renderer := NewHTMLRenderer(HTMLRendererParameters{ - Flags: CommonHTMLFlags, - Extensions: CommonExtensions, + Flags: CommonHTMLFlags, }) return Markdown(input, renderer, DefaultOptions) }