yuin / goldmark

:trophy: A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.
MIT License
3.68k stars 255 forks source link

"Smart" punctuation with Typographer is double-escaped in image alt text #321

Closed ObjectBoxPC closed 2 years ago

ObjectBoxPC commented 2 years ago
  1. What version of goldmark are you using? : 1.4.13
  2. What version of Go are you using? : 1.18.5
  3. What operating system and processor architecture are you using? : Linux (Debian), x86-64
  4. What did you do? : Render the following source with the Typographer extension enabled:
    ![Nice day, isn't it?](https://example.com/image.jpg)
  5. What did you expect to see? :
    <p><img src="https://example.com/image.jpg" alt="Nice day, isn&rsquo;t it?"></p>
  6. What did you see instead? :
    <p><img src="https://example.com/image.jpg" alt="Nice day, isn&amp;rsquo;t it?"></p>
  7. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension?: Since this relates to an extension, I tested with a different implementation with a similar extension, gomarkdown. The output from that implementation is what I expect.
ObjectBoxPC commented 2 years ago

Test program to reproduce the issue:

package main

import (
    "bytes"
    "fmt"
    "github.com/yuin/goldmark"
    "github.com/yuin/goldmark/extension"
)

func main() {
    var outputBuffer bytes.Buffer
    input := []byte("![Nice day, isn't it?](https://example.com/image.jpg)")
    parser := goldmark.New(
        goldmark.WithExtensions(extension.Typographer),
    )
    parser.Convert(input, &outputBuffer)
    output := string(outputBuffer.Bytes())
    fmt.Println(output)
}