Skip to content

Commit

Permalink
Fix problem with escaped ampersands
Browse files Browse the repository at this point in the history
  • Loading branch information
raykov committed May 13, 2021
1 parent 8df6650 commit ea412c8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions example/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Strikethrough uses two tildes. ~~Scratch this.~~

[You can use numbers for reference-style link definitions][1]

[I'm a link with ampersands](https://www.google.com?some=information&another[]=list&another[]=information)

Or leave it empty and use the [link text itself].

URLs and URLs in angle brackets will automatically get turned into links.
Expand Down
Binary file modified example/example.pdf
Binary file not shown.
6 changes: 3 additions & 3 deletions renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (r *Renderer) renderAutoLink(w Writer, source []byte, node ast.Node, enteri
return ast.WalkContinue, nil
}

url := string(util.EscapeHTML(util.URLEscape(n.URL(source), false)))
url := string(util.URLEscape(n.URL(source), false))
if n.AutoLinkType == ast.AutoLinkEmail && !strings.HasPrefix(strings.ToLower(url), "mailto:") {
w.SetLink("mailto:" + url)
} else {
Expand Down Expand Up @@ -255,7 +255,7 @@ func (r *Renderer) renderImage(w Writer, source []byte, node ast.Node, entering
}
n := node.(*ast.Image)

filePath := string(util.EscapeHTML(util.URLEscape(n.Destination, true)))
filePath := string(util.URLEscape(n.Destination, true))
inlineImg := "data:image/"

switch {
Expand Down Expand Up @@ -302,7 +302,7 @@ func (r *Renderer) renderImage(w Writer, source []byte, node ast.Node, entering
func (r *Renderer) renderLink(w Writer, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
n := node.(*ast.Link)
if entering {
w.SetLink(string(util.EscapeHTML(util.URLEscape(n.Destination, true))))
w.SetLink(string(util.URLEscape(n.Destination, true)))
currStyle := w.CurrentStyle()
newStyle := currStyle.Clone()
newStyle.FontStyle += "U"
Expand Down

0 comments on commit ea412c8

Please sign in to comment.