mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	tpl/transform: Fix it when template.HTML is passes as option to Hightlight
Fixes #9591
This commit is contained in:
		@@ -122,10 +122,13 @@ func applyOptions(opts interface{}, cfg *Config) error {
 | 
				
			|||||||
	switch vv := opts.(type) {
 | 
						switch vv := opts.(type) {
 | 
				
			||||||
	case map[string]interface{}:
 | 
						case map[string]interface{}:
 | 
				
			||||||
		return applyOptionsFromMap(vv, cfg)
 | 
							return applyOptionsFromMap(vv, cfg)
 | 
				
			||||||
	case string:
 | 
						default:
 | 
				
			||||||
		return applyOptionsFromString(vv, cfg)
 | 
							s, err := cast.ToStringE(opts)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return applyOptionsFromString(s, cfg)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func applyOptionsFromString(opts string, cfg *Config) error {
 | 
					func applyOptionsFromString(opts string, cfg *Config) error {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,7 @@ package transform_test
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"html/template"
 | 
						"html/template"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gohugoio/hugo/common/loggers"
 | 
						"github.com/gohugoio/hugo/common/loggers"
 | 
				
			||||||
@@ -81,6 +82,8 @@ func TestHighlight(t *testing.T) {
 | 
				
			|||||||
		// Issue #4179
 | 
							// Issue #4179
 | 
				
			||||||
		{`<Foo attr=" < "></Foo>`, "xml", "", `&lt;`},
 | 
							{`<Foo attr=" < "></Foo>`, "xml", "", `&lt;`},
 | 
				
			||||||
		{tstNoStringer{}, "go", "", false},
 | 
							{tstNoStringer{}, "go", "", false},
 | 
				
			||||||
 | 
							// Issue #9591
 | 
				
			||||||
 | 
							{strings.Repeat("AAA	\n", 10), "bash", template.HTML("linenos=true,noClasses=false"), "line"},
 | 
				
			||||||
	} {
 | 
						} {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		result, err := ns.Highlight(test.s, test.lang, test.opts)
 | 
							result, err := ns.Highlight(test.s, test.lang, test.opts)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user