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

Wiki links do not handle spaces correctly #3506

Closed
1 of 3 tasks
dakira opened this issue Feb 13, 2018 · 2 comments
Closed
1 of 3 tasks

Wiki links do not handle spaces correctly #3506

dakira opened this issue Feb 13, 2018 · 2 comments
Labels
Milestone

Comments

@dakira
Copy link
Contributor

dakira commented Feb 13, 2018

Description

A link like [[My Article]] links to My+Article.md where it rather should link to My-Article.md. The Sidebar links in the above copy of the microsoft/vscode-wiki are a good example.

@charlesreid1
Copy link
Contributor

charlesreid1 commented Feb 22, 2018

Looks like the relevant wiki template file is templates/repo/wiki/view.tmpl on line 88, which contains:

{{.sidebarContent | Str2html}}

Str2html is a Go library imported by helper.go that turns markdown into HTML. It is unlikely the links are being improperly rendered by Str2html.

The sidebarContent variable is loaded and set in wiki.go.

This loads the sidebar content from wikiContentsByName() (later in the same wiki.go file).

It renders the final sidebar content by calling markdown.RenderWiki(), which just calls markup.RenderWiki in markup.go. This, in turn, calls a couple of layers of render functions, all in markup.go, until we get to the render() function in markup.go, which contains the culprit line:

func render(parser Parser, rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte {
	urlPrefix = strings.Replace(urlPrefix, " ", "+", -1) /* <----- O NOES !!!!!! */
	result := parser.Render(rawBytes, urlPrefix, metas, isWiki)
	result = PostProcess(result, urlPrefix, metas, isWiki)
	return SanitizeBytes(result)
}

@dakira
Copy link
Contributor Author

dakira commented Feb 22, 2018

@charlesreid1 you are awesome. Thanks for the detailed explanation, too!

@lafriks lafriks added this to the 1.4.0 milestone Mar 5, 2018
@lafriks lafriks modified the milestones: 1.4.0, 1.5.0 Mar 5, 2018
@lafriks lafriks closed this as completed Mar 5, 2018
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants