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

Tables are still not working correctly #23

Open
TLINDEN opened this issue Aug 14, 2024 · 0 comments
Open

Tables are still not working correctly #23

TLINDEN opened this issue Aug 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@TLINDEN
Copy link

TLINDEN commented Aug 14, 2024

Hi,

even though issue #1 is closed, it still does not work for me. The column width seems to be calculated based on header text length, not the actual header length (including spaces).

This is the table in question:

| Nummer  | Beschreibung des Tests                            | Ergebnis  |
| ------- | ------------------------------------------------- | --------- |
|1|Status der postgres instanzen auf dem Cluster|Ok|

This is how it looks in the PDF.
table

I also tried this:

| Nummer  | Beschreibung des Tests                        | Ergebnis  |
| ------- | --------------------------------------------- | --------- |
| 1       | Status der postgres instanzen auf dem Cluster | Ok        |

with the same result.

This is how I generate the PDF:

	markdown := goldmark.New(
		goldmark.WithRenderer(
			pdf.New(
				pdf.WithTraceWriter(os.Stdout),
				pdf.WithContext(context.Background()),
				pdf.WithHeadingFont(pdf.GetTextFont("IBM Plex Serif", pdf.FontLora)),
				pdf.WithBodyFont(pdf.GetTextFont("Open Sans", pdf.FontRoboto)),
				pdf.WithCodeFont(pdf.GetCodeFont("Inconsolata", pdf.FontRobotoMono)),
			),
		),
		goldmark.WithExtensions(extension.GFM, extension.Table), // required for tables
	)

	// now the actual rendering to PDF
	var buf bytes.Buffer
	if err := markdown.Convert(mdsource, &buf); err != nil {
		return fmt.Errorf("failed to render markdown to pdf: %w", err)
	}

This is the relevant debug output:

[Table (entering)]                           
-[TableHead (entering)]                                                                               
--[TableCell (entering)] 
---[Text] Nummer                                                                                                                                                                                             
---[... table header cell] Width=74.256, height=14
--[TableCell (leaving)] 
--[TableCell (entering)] 
---[Text] Beschreibung des Tests
---[... table header cell] Width=156.56400000000002, height=14
--[TableCell (leaving)] 
--[TableCell (entering)] 
---[Text] Ergebnis
---[... table header cell] Width=73.32, height=14
--[TableCell (leaving)] 
-[TableHead (leaving)] 
-[TableRow (entering)] 
--[TableCell (entering)] 
---[Text] 1
---[... table body cell] Width=74.256, height=14
--[TableCell (leaving)] 
--[TableCell (entering)] 
---[Text] Status der postgres instanzen auf dem Cluster
---[... table body cell] Width=156.56400000000002, height=14
--[TableCell (leaving)] 
--[TableCell (entering)] 
---[Text] Ok
---[... table body cell] Width=73.32, height=14
--[TableCell (leaving)] 
-[TableRow (leaving)] 
[Table (leaving)] 

So it seems like the cell width of the second column matches the one of the header. But the rendered result tells another story.

@stephenafamo stephenafamo added the bug Something isn't working label Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants