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

Table detection requires preceding empty line in contravention with GFM spec #148

Closed
4 tasks done
zeripath opened this issue Jul 30, 2020 · 2 comments
Closed
4 tasks done

Comments

@zeripath
Copy link

  • goldmark is fully compliant with the CommonMark. Before submitting issue, you must read CommonMark spec and confirm your output is different from CommonMark online demo.
    • Extensions(Autolink without < >, Table, etc) are not part of CommonMark spec. You should confirm your output is different from other official renderers correspond with an extension.
  • goldmark is not dedicated for Hugo. If you are Hugo user and your issue was raised by your experience in Hugo, you should consider create issue at Hugo repository at first .
  • Before you make a feature request, you should consider implement the new feature as an extension by yourself . To keep goldmark itself simple, most new features should be implemented as an extension.

Please answer the following before submitting your issue:

  1. What version of goldmark are you using? : v1.1.32
  2. What version of Go are you using? : 1.14.6
  3. What operating system and processor architecture are you using? : Linux x86_64
  4. What did you do?
**xxx**
| hello |   hi  |
| :----: | :----:|
  1. What did you expect to see? :
<p><strong>xxx</strong></p>
<table role="table">
<thead>
<tr>
<th align="center">hello</th>
<th align="center">hi</th>
</tr>
</thead>
</table>
  1. What did you see instead? :
<strong>xxx</strong>
| hello |   hi  |
| :----: | :----:|
  1. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension?:

Yes differs from GFM

  1. (Feature request only): Why you can not implement it as an extension?:
    • You should avoid saying like "I'm not familiar with this project" "I'm not a Go programmer" as far as possible. This is an open source project and a library for Go programmers. I encourage you to strive to read source codes.
    • I absolutely welcome questions that are difficult even if you read the source codes.
      N/A

Dear @yuin,

Thank you so much for your work on Goldmark - it really is excellent.

A user on Gitea has noticed the above problem with the Table extension and reported it as go-gitea/gitea#12376.

As far as I can see, I don't think that this is a bug specific to Gitea's use of Goldmark. The following code appears to replicate the issue:

package main

import (
	"bytes"
        "fmt"

	"github.com/yuin/goldmark"
	"github.com/yuin/goldmark/extension"
	"github.com/yuin/goldmark/parser"
	"github.com/yuin/goldmark/renderer/html"
)

func main() {

	md := goldmark.New(
		goldmark.WithExtensions(extension.GFM),
		goldmark.WithParserOptions(
			parser.WithAutoHeadingID(),
		),
		goldmark.WithRendererOptions(
			html.WithHardWraps(),
			html.WithXHTML(),
		),
	)
	var buf bytes.Buffer
	if err := md.Convert([]byte(`
**xxx**
| hello |   hi  |
| :----: | :----:|	
	`), &buf); err != nil {
		panic(err)
	}

	fmt.Println(buf.String())

}
@jacky-2014-sn
Copy link

jacky-2014-sn commented Jul 30, 2020

As Github, when table is include in paragraph, It show as paragraph and table.
Add a table check, then deal the lines before table as paragraph and the table will be table.
So far,It works as Github. But, I worry about it has something others.

@yuin yuin closed this as completed in 91e5269 Jul 30, 2020
@zeripath
Copy link
Author

Thanks @yuin!

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

No branches or pull requests

2 participants