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

Panic in renderText #16

Open
ivanjaros opened this issue Feb 6, 2023 · 2 comments
Open

Panic in renderText #16

ivanjaros opened this issue Feb 6, 2023 · 2 comments

Comments

@ivanjaros
Copy link

ivanjaros commented Feb 6, 2023

Source:

test

My favorite search engine is [Duck Duck Go](https://duckduckgo.com).

![The San Juan Mountains are beautiful!](https://mdg.imgix.net/assets/images/san-juan-mountains.jpg?auto=format&fit=clip&q=40&w=1080 "San Juan Mountains")

Here's our logo (hover to see the title text):

Inline-style: 
![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")

Reference-style: 
![alt text][logo]

[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"

ok.

returns

panic: interface conversion: ast.Node is *ast.String, not *ast.Text

goroutine 1 [running]:
github.com/stephenafamo/goldmark-pdf.(*nodeRederFuncs).renderText(0xc0002cc7ec?, 0xd2f3a0?, {0xc0003c4000?, 0x0?, 0x0?}, {0xd3dde0?, 0xc0000df3b0?}, 0x0?)
        G:/Go/pkg/mod/github.com/stephenafamo/goldmark-pdf@v0.2.0/renderer_funcs.go:138 +0xd0
github.com/stephenafamo/goldmark-pdf.(*renderer).Render.func2({0xd3dde0, 0xc0000df3b0}, 0x80?)
        G:/Go/pkg/mod/github.com/stephenafamo/goldmark-pdf@v0.2.0/renderer.go:103 +0xb6
github.com/yuin/goldmark/ast.walkHelper({0xd3dde0, 0xc0000df3b0}, 0xc000515d08)
        G:/Go/pkg/mod/github.com/yuin/goldmark@v1.5.3/ast/ast.go:492 +0x34
github.com/yuin/goldmark/ast.walkHelper({0xd3dba0, 0xc000036e00}, 0xc000515d08)
        G:/Go/pkg/mod/github.com/yuin/goldmark@v1.5.3/ast/ast.go:498 +0x8e
github.com/yuin/goldmark/ast.walkHelper({0xd3d180, 0xc0000defc0}, 0xc000515d08)
        G:/Go/pkg/mod/github.com/yuin/goldmark@v1.5.3/ast/ast.go:498 +0x8e
github.com/yuin/goldmark/ast.Walk(...)
        G:/Go/pkg/mod/github.com/yuin/goldmark@v1.5.3/ast/ast.go:487
github.com/stephenafamo/goldmark-pdf.(*renderer).Render(0xc000356440, {0xd2ede0, 0xc00008a038}, {0xc0003c4000, 0x230, 0x380}, {0xd3d180, 0xc0000defc0})
        G:/Go/pkg/mod/github.com/stephenafamo/goldmark-pdf@v0.2.0/renderer.go:98 +0x632
github.com/yuin/goldmark.(*markdown).Convert(0xc000356480, {0xc0003c4000, 0x230, 0x380}, {0xd2ede0, 0xc00008a038}, {0x0, 0x0, 0x0})

obrázok

@stephenafamo stephenafamo added bug Something isn't working can't reproduce and removed bug Something isn't working labels Feb 9, 2023
@stephenafamo
Copy link
Owner

I can't seem to reproduce this. Can you share more details (OS, Go Version, go.mod)

@cuboci
Copy link

cuboci commented May 27, 2024

I seem to have the same problem. Simple setup to reproduce:

This is on Debian Sid with Go version 1.22.3 from official binaries.

go.mod

module markdowntest

go 1.22.3

require (
	github.com/stephenafamo/goldmark-pdf v0.4.1
	github.com/yuin/goldmark v1.7.1
)

require (
	github.com/alecthomas/chroma/v2 v2.10.0 // indirect
	github.com/dlclark/regexp2 v1.10.0 // indirect
	github.com/go-swiss/fonts v0.0.0-20221219152310-0b267088f53d // indirect
	github.com/jellydator/ttlcache/v3 v3.1.0 // indirect
	github.com/phpdave11/gofpdf v1.4.2 // indirect
	golang.org/x/sync v0.1.0 // indirect
)

main.go

package main

import (
	"io"
	"log"
	"os"

	pdf "github.com/stephenafamo/goldmark-pdf"
	"github.com/yuin/goldmark"
	"github.com/yuin/goldmark/extension"
	"github.com/yuin/goldmark/renderer/html"
)

func main() {
	md := goldmark.New(
		goldmark.WithExtensions(extension.GFM, extension.Table, extension.Typographer, extension.Footnote),
		goldmark.WithRenderer(pdf.New()),
		goldmark.WithRendererOptions(html.WithXHTML()),
	)

	buf, err := io.ReadAll(os.Stdin)
	if err != nil {
		log.Fatal(err)
	}
	if err := md.Convert(buf, os.Stdout); err != nil {
		log.Fatal(err)
	}
}

input

# h1 -- first

## h2 --- 'second'

- list item 1
- list item 2
    - list item 2.1

| foo | bar |
:--- | ---:
| x | y |

Footnote[^1]

[^1]: Here be dragons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants