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

Docs: Mention alternative package for generating Markdown tables #7

Closed
2 tasks done
montanaflynn opened this issue Jul 22, 2024 · 1 comment · Fixed by #8
Closed
2 tasks done

Docs: Mention alternative package for generating Markdown tables #7

montanaflynn opened this issue Jul 22, 2024 · 1 comment · Fixed by #8
Assignees
Labels
area: documentation Improvements or additions to docs 📝 status: accepting prs Please, send a pull request to resolve this! 🙏

Comments

@montanaflynn
Copy link

Bug Report Checklist

Overview

horizontalSeparator gets very close to markdown tables, if it could also put a separator under the first row it would be a fully compliant markdown table. I like to print tables that can be copied and pasted into issues or markdown files.

Without header separator:

abc  | abcd |  abc
1234 |  12  | 1234

abc | abcd | abc
1234 | 12 | 1234

With header separator:

abc  | abcd |  abc
---- | ---- | ----
1234 |  12  | 1234
abc abcd abc
1234 12 1234

Additional Info

No response

@montanaflynn montanaflynn added the type: feature New enhancement or request 🚀 label Jul 22, 2024
@JoshuaKGoldberg JoshuaKGoldberg added area: documentation Improvements or additions to docs 📝 and removed type: feature New enhancement or request 🚀 labels Jul 24, 2024
@JoshuaKGoldberg
Copy link
Owner

Hey thanks for suggesting this @montanaflynn! It didn't occur to me just how close this package is to Markdown tables, good spot.

But, actually getting compliant Markdown tables would be a bit more involved than this. There are a lot of edge cases around cell data sanitization that'd have to be accounted for. For example, cells with special characters such as '|' and '\n':

import { textTable } from "text-table";

console.log(
	textTable(
		[["a", "|", "\n", "z"]],
		{ horizontalSeparator: "|" },
	),
);
a|||
|z

This package is very small right now. Adding in handling for those and other encoding things would increase its size a lot and hurt runtime performance.

I think it'd make sense to instead link to a dedicated package for a markdown table in the README.md. Adding docs would help explain that this package is just for very basic + quick table layout, not full Markdown / GFM workability. A quick Google/npm search shows https://www.npmjs.com/package/markdown-table - which actually mentions the original text-table at the bottom of its README.md!

@JoshuaKGoldberg JoshuaKGoldberg changed the title Add support for header separator to make valid markdown tables Docs: Mention alternative package for generating Markdown tables Jul 24, 2024
@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Jul 24, 2024
@JoshuaKGoldberg JoshuaKGoldberg added the status: accepting prs Please, send a pull request to resolve this! 🙏 label Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: documentation Improvements or additions to docs 📝 status: accepting prs Please, send a pull request to resolve this! 🙏
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants