2011-06-02 02:52:24 +02:00
|
|
|
//
|
2011-06-28 04:11:32 +02:00
|
|
|
// Blackfriday Markdown Processor
|
2022-01-06 18:49:55 +01:00
|
|
|
// Available at http://github.com/danog/blackfriday
|
2011-06-28 04:11:32 +02:00
|
|
|
//
|
|
|
|
// Copyright © 2011 Russ Ross <russ@russross.com>.
|
2011-06-28 19:30:10 +02:00
|
|
|
// Distributed under the Simplified BSD License.
|
2011-06-28 04:11:32 +02:00
|
|
|
// See README.md for details.
|
2011-06-02 02:52:24 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Markdown 1.0.3 reference tests
|
|
|
|
//
|
|
|
|
|
|
|
|
package blackfriday
|
|
|
|
|
2016-07-25 18:39:51 +02:00
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
)
|
2011-06-02 02:52:24 +02:00
|
|
|
|
|
|
|
func TestReference(t *testing.T) {
|
2018-09-07 23:47:14 +02:00
|
|
|
t.Parallel()
|
2011-06-02 02:52:24 +02:00
|
|
|
files := []string{
|
|
|
|
"Amps and angle encoding",
|
|
|
|
"Auto links",
|
|
|
|
"Backslash escapes",
|
|
|
|
"Blockquotes with code blocks",
|
|
|
|
"Code Blocks",
|
|
|
|
"Code Spans",
|
|
|
|
"Hard-wrapped paragraphs with list-like lines",
|
|
|
|
"Horizontal rules",
|
|
|
|
"Inline HTML (Advanced)",
|
|
|
|
"Inline HTML (Simple)",
|
|
|
|
"Inline HTML comments",
|
|
|
|
"Links, inline style",
|
|
|
|
"Links, reference style",
|
|
|
|
"Links, shortcut references",
|
|
|
|
"Literal quotes in titles",
|
|
|
|
"Markdown Documentation - Basics",
|
|
|
|
"Markdown Documentation - Syntax",
|
|
|
|
"Nested blockquotes",
|
|
|
|
"Ordered and unordered lists",
|
|
|
|
"Strong and em together",
|
|
|
|
"Tabs",
|
|
|
|
"Tidyness",
|
|
|
|
}
|
2013-07-30 04:32:11 +02:00
|
|
|
doTestsReference(t, files, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestReference_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) {
|
2018-09-07 23:47:14 +02:00
|
|
|
t.Parallel()
|
2013-07-30 04:32:11 +02:00
|
|
|
files := []string{
|
|
|
|
"Amps and angle encoding",
|
|
|
|
"Auto links",
|
|
|
|
"Backslash escapes",
|
|
|
|
"Blockquotes with code blocks",
|
|
|
|
"Code Blocks",
|
|
|
|
"Code Spans",
|
|
|
|
"Hard-wrapped paragraphs with list-like lines no empty line before block",
|
|
|
|
"Horizontal rules",
|
|
|
|
"Inline HTML (Advanced)",
|
|
|
|
"Inline HTML (Simple)",
|
|
|
|
"Inline HTML comments",
|
|
|
|
"Links, inline style",
|
|
|
|
"Links, reference style",
|
|
|
|
"Links, shortcut references",
|
|
|
|
"Literal quotes in titles",
|
|
|
|
"Markdown Documentation - Basics",
|
|
|
|
"Markdown Documentation - Syntax",
|
|
|
|
"Nested blockquotes",
|
|
|
|
"Ordered and unordered lists",
|
|
|
|
"Strong and em together",
|
|
|
|
"Tabs",
|
|
|
|
"Tidyness",
|
|
|
|
}
|
2015-10-26 17:16:57 +01:00
|
|
|
doTestsReference(t, files, NoEmptyLineBeforeBlock)
|
2011-06-02 02:52:24 +02:00
|
|
|
}
|
2016-07-25 18:39:51 +02:00
|
|
|
|
|
|
|
// benchResultAnchor is an anchor variable to store the result of a benchmarked
|
|
|
|
// code so that compiler could never optimize away the call to runMarkdown()
|
|
|
|
var benchResultAnchor string
|
|
|
|
|
|
|
|
func BenchmarkReference(b *testing.B) {
|
2017-02-02 08:35:10 +01:00
|
|
|
params := TestParams{extensions: CommonExtensions}
|
2016-07-25 18:39:51 +02:00
|
|
|
files := []string{
|
|
|
|
"Amps and angle encoding",
|
|
|
|
"Auto links",
|
|
|
|
"Backslash escapes",
|
|
|
|
"Blockquotes with code blocks",
|
|
|
|
"Code Blocks",
|
|
|
|
"Code Spans",
|
|
|
|
"Hard-wrapped paragraphs with list-like lines",
|
|
|
|
"Horizontal rules",
|
|
|
|
"Inline HTML (Advanced)",
|
|
|
|
"Inline HTML (Simple)",
|
|
|
|
"Inline HTML comments",
|
|
|
|
"Links, inline style",
|
|
|
|
"Links, reference style",
|
|
|
|
"Links, shortcut references",
|
|
|
|
"Literal quotes in titles",
|
|
|
|
"Markdown Documentation - Basics",
|
|
|
|
"Markdown Documentation - Syntax",
|
|
|
|
"Nested blockquotes",
|
|
|
|
"Ordered and unordered lists",
|
|
|
|
"Strong and em together",
|
|
|
|
"Tabs",
|
|
|
|
"Tidyness",
|
|
|
|
}
|
|
|
|
var tests []string
|
|
|
|
for _, basename := range files {
|
|
|
|
filename := filepath.Join("testdata", basename+".text")
|
|
|
|
inputBytes, err := ioutil.ReadFile(filename)
|
|
|
|
if err != nil {
|
|
|
|
b.Errorf("Couldn't open '%s', error: %v\n", filename, err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
tests = append(tests, string(inputBytes))
|
|
|
|
}
|
2016-07-30 20:40:13 +02:00
|
|
|
b.ResetTimer()
|
2016-07-25 18:39:51 +02:00
|
|
|
for n := 0; n < b.N; n++ {
|
|
|
|
for _, test := range tests {
|
|
|
|
benchResultAnchor = runMarkdown(test, params)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|