Fix URL handling in the whole markdown module, improve test coverage (#1027)

Amended with string to bool change in API SDK.

Signed-off-by: Andrew Boyarshin <andrew.boyarshin@gmail.com>
This commit is contained in:
Andrew Boyarshin 2017-02-24 21:59:56 +07:00 committed by Lunny Xiao
parent 12e71e5706
commit 0602a44b27
6 changed files with 273 additions and 152 deletions

View file

@ -27,7 +27,13 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
switch form.Mode {
case "gfm":
ctx.Write(markdown.Render([]byte(form.Text), markdown.URLJoin(setting.AppURL, form.Context), nil))
md := []byte(form.Text)
context := markdown.URLJoin(setting.AppURL, form.Context)
if form.Wiki {
ctx.Write([]byte(markdown.RenderWiki(md, context, nil)))
} else {
ctx.Write(markdown.Render(md, context, nil))
}
default:
ctx.Write(markdown.RenderRaw([]byte(form.Text), "", false))
}