internal/web: stop double-escaping of code in non-playground examples
4c9e549253
introduced an issue causing non-playground
code examples to be double-escaped, causing HTML escape sequences and elements
to appear in the code, such as the examples in crypto/rsa, as reported in golang/go#46839.
This change treats the code as `template.HTML` rather than `string` after running
through `(*Page).Node` (which formats the code as HTML) and doing some basic transformations,
preventing this double-escaping from occurring.
Fixes golang/go#46839
This commit is contained in:
Родитель
d6de7f00de
Коммит
e5adf7c7f5
|
@ -74,9 +74,10 @@ func (p *Page) Example(funcName string) template.HTML {
|
|||
|
||||
newPage := *p
|
||||
newPage.Data = struct {
|
||||
Name, Doc, Code, Play, Output string
|
||||
Name, Doc, Play, Output string
|
||||
Code template.HTML
|
||||
}{
|
||||
eg.Name, eg.Doc, code, play, out,
|
||||
eg.Name, eg.Doc, play, out, template.HTML(code),
|
||||
}
|
||||
err := t.Execute(&buf, &newPage)
|
||||
if err != nil {
|
||||
|
|
Загрузка…
Ссылка в новой задаче