"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "markup/goldmark/convert_test.go" between
hugo-0.80.0.tar.gz and hugo-0.81.0.tar.gz

About: Hugo is a static site generator that takes a source directory of Markdown files and templates and uses these as input to create a complete website (written in Go).

convert_test.go  (hugo-0.80.0):convert_test.go  (hugo-0.81.0)
skipping to change at line 20 skipping to change at line 20
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package goldmark package goldmark
import ( import (
"strings" "strings"
"testing" "testing"
"github.com/spf13/cast"
"github.com/gohugoio/hugo/markup/goldmark/goldmark_config" "github.com/gohugoio/hugo/markup/goldmark/goldmark_config"
"github.com/gohugoio/hugo/markup/highlight" "github.com/gohugoio/hugo/markup/highlight"
"github.com/gohugoio/hugo/markup/markup_config" "github.com/gohugoio/hugo/markup/markup_config"
"github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/markup/converter" "github.com/gohugoio/hugo/markup/converter"
skipping to change at line 193 skipping to change at line 195
` `
mconf := markup_config.Default mconf := markup_config.Default
mconf.Goldmark.Parser.AutoHeadingIDType = goldmark_config.AutoHeadingIDTy peBlackfriday mconf.Goldmark.Parser.AutoHeadingIDType = goldmark_config.AutoHeadingIDTy peBlackfriday
b := convert(c, mconf, content) b := convert(c, mconf, content)
got := string(b.Bytes()) got := string(b.Bytes())
c.Assert(got, qt.Contains, "<h2 id=\"let-s-try-this-shall-we\">") c.Assert(got, qt.Contains, "<h2 id=\"let-s-try-this-shall-we\">")
} }
func TestConvertAttributes(t *testing.T) {
c := qt.New(t)
withBlockAttributes := func(conf *markup_config.Config) {
conf.Goldmark.Parser.Attribute.Block = true
conf.Goldmark.Parser.Attribute.Title = false
}
withTitleAndBlockAttributes := func(conf *markup_config.Config) {
conf.Goldmark.Parser.Attribute.Block = true
conf.Goldmark.Parser.Attribute.Title = true
}
for _, test := range []struct {
name string
withConfig func(conf *markup_config.Config)
input string
expect interface{}
}{
{
"Title",
nil,
"## heading {#id .className attrName=attrValue class=\"cl
ass1 class2\"}",
"<h2 id=\"id\" class=\"className class1 class2\" attrName
=\"attrValue\">heading</h2>\n",
},
{
"Blockquote",
withBlockAttributes,
"> foo\n> bar\n{#id .className attrName=attrValue class=\
"class1 class2\"}\n",
"<blockquote id=\"id\" class=\"className class1 class2\">
<p>foo\nbar</p>\n</blockquote>\n",
},
{
"Paragraph",
withBlockAttributes,
"\nHi there.\n{.myclass }",
"<p class=\"myclass\">Hi there.</p>\n",
},
{
"Ordered list",
withBlockAttributes,
"\n1. First\n2. Second\n{.myclass }",
"<ol class=\"myclass\">\n<li>First</li>\n<li>Second</li>\
n</ol>\n",
},
{
"Unordered list",
withBlockAttributes,
"\n* First\n* Second\n{.myclass }",
"<ul class=\"myclass\">\n<li>First</li>\n<li>Second</li>\
n</ul>\n",
},
{
"Unordered list, indented",
withBlockAttributes,
`* Fruit
* Apple
* Orange
* Banana
{.fruits}
* Dairy
* Milk
* Cheese
{.dairies}
{.list}`,
[]string{"<ul class=\"list\">\n<li>Fruit\n<ul class=\"fru
its\">", "<li>Dairy\n<ul class=\"dairies\">"},
},
{
"Table",
withBlockAttributes,
`| A | B |
| ------------- |:-------------:| -----:|
| AV | BV |
{.myclass }`,
"<table class=\"myclass\">\n<thead>",
},
{
"Title and Blockquote",
withTitleAndBlockAttributes,
"## heading {#id .className attrName=attrValue class=\"cl
ass1 class2\"}\n> foo\n> bar\n{.myclass}",
"<h2 id=\"id\" class=\"className class1 class2\" attrName
=\"attrValue\">heading</h2>\n<blockquote class=\"myclass\"><p>foo\nbar</p>\n</bl
ockquote>\n",
},
} {
c.Run(test.name, func(c *qt.C) {
mconf := markup_config.Default
if test.withConfig != nil {
test.withConfig(&mconf)
}
b := convert(c, mconf, test.input)
got := string(b.Bytes())
for _, s := range cast.ToStringSlice(test.expect) {
c.Assert(got, qt.Contains, s)
}
})
}
}
func TestConvertIssues(t *testing.T) { func TestConvertIssues(t *testing.T) {
c := qt.New(t) c := qt.New(t)
// https://github.com/gohugoio/hugo/issues/7619 // https://github.com/gohugoio/hugo/issues/7619
c.Run("Hyphen in HTML attributes", func(c *qt.C) { c.Run("Hyphen in HTML attributes", func(c *qt.C) {
mconf := markup_config.Default mconf := markup_config.Default
mconf.Goldmark.Renderer.Unsafe = true mconf.Goldmark.Renderer.Unsafe = true
input := `<custom-element> input := `<custom-element>
<div>This will be "slotted" into the custom element.</div> <div>This will be "slotted" into the custom element.</div>
</custom-element> </custom-element>
 End of changes. 2 change blocks. 
0 lines changed or deleted 109 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)