Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/website/internal/talks: go.dev/talks doesn't parse legacy present formatting syntax #50664

Closed
dmitshur opened this issue Jan 18, 2022 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dmitshur
Copy link
Contributor

https://go.dev/talks hosts some Go talks, many of which use the legacy present syntax (rather than the newer Markdown syntax). The legacy present syntax supports some formatting features, such as:

Formatting:

_italic_
*bold*
`program`
Markup—_especially_italic_text_—can easily be overused.
_Why_use_scoped__ptr_? Use plain ***ptr* instead.

Visit [[https://golang.org][the Go home page]].

This syntax is not parsed in the talks displayed at https://go.dev/talks. Some examples of the breakage:

This syntax is correctly parsed by golang.org/x/tools/cmd/present tool, so this is an x/website-specific bug.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 18, 2022
@dmitshur dmitshur added this to the Unreleased milestone Jan 18, 2022
@dmitshur
Copy link
Contributor Author

It seems the relevant parsing/conversion happens in present.Style:

// Style returns s with HTML entities escaped and font indicators turned into
// HTML font tags.
func Style(s string) template.HTML {
	return template.HTML(font(html.EscapeString(s)))
}

// font returns s with font indicators turned into HTML font tags.
func font(s string) string { ... }

x/website/internal/web defines a wrapper around it:

func presentStyle(s string) template.HTML {
	return template.HTML(present.Style(s))
}

And makes it available as a template function:

t := template.New("site.tmpl").Funcs(template.FuncMap{
	...
	"presentStyle": presentStyle,
})

But then overrides it with a no-op template:

{{define "presentStyle"}}{{.}}{{end}}

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jan 18, 2022
@dmitshur dmitshur self-assigned this Jan 18, 2022
@gopherbot
Copy link

Change https://golang.org/cl/379035 mentions this issue: _content/talks: delete "presentStyle" template

passionSeven added a commit to passionSeven/website that referenced this issue Oct 18, 2022
With no "presentStyle" template defined, the template function with
the same name (defined in the internal/web package) starts to be used
in its place. Unlike the no-op wrapper template, the template function
correctly processes some of the legacy present syntax.

Fixes golang/go#50664.

Change-Id: I8a673e511b326f5c4f8a3a2666a2d1e65b5995ce
Reviewed-on: https://go-review.googlesource.com/c/website/+/379035
Reviewed-by: Jamal Carvalho <jamalcarvalho@google.com>
Trust: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants