stephenafamo / goldmark-pdf

A PDF renderer for the goldmark markdown parser.
MIT License
123 stars 14 forks source link

Rendering quotes #17

Open idroz opened 1 year ago

idroz commented 1 year ago

Thanks for a great package. Is there a way to customise the renderer to parse quotes correctly.

Consider source:

source := `"Just a test"`
markdown := goldmark.New(
        goldmark.WithRenderer(
        pdf.New(
                pdf.WithHeadingFont(pdf.GetTextFont("Times", pdf.FontTimes)),
                pdf.WithBodyFont(pdf.GetTextFont("Times", pdf.FontTimes)),
        )),

    )

var buf bytes.Buffer
if err := markdown.Convert([]byte(source), &buf); err != nil {
return err
}

buf.Bytes()

Will produce:

"Just a test"

The desired output is "Just a test"

I presume this has to do with passing correct options to WithNodeRenderers(), but struggling to see what those are from the source code.

Thanks for the help!

stephenafamo commented 1 year ago

I suspect this has something to do with encoding HTML entities. Maybe because of some copied code from the HTML renderer. I'll take a look.

idroz commented 1 year ago

A similar "issue" was present in the default gold mark html renderer and I managed to solve it by passing html.WithXHTML() to goldmark.WithRendererOptions.