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

Helper function to style as Markdown table #111

Closed
TylerRick opened this issue Jun 23, 2020 · 1 comment
Closed

Helper function to style as Markdown table #111

TylerRick opened this issue Jun 23, 2020 · 1 comment

Comments

@TylerRick
Copy link

For those of us who are already using this gem and don't want to install yet another dependency like markdown-tables just to get a more concise API for generating Markdown tables.

Thanks to this library's configurability, you can already format your tables as Markdown format:

markdown_style = {
  border_top:    false,
  border_bottom: false,
  border_x:      "-",
  border_y:      "|",
  border_i:      "|"
}
puts Terminal::Table.new(headings: ['heading A', 'heading B'], rows: [['a', 'b'], ['a', 'b']], style: markdown_style)
| heading A | heading B |
|-----------|-----------|
| a         | b         |
| a         | b         |

But it would be nice if we end-users didn't have to copy and paste that big markdown_style hash every place we wanted to output a table in Markdown format.

How about something like:

Terminal::Table.new(...).as_markdown

that would automatically add style: markdown_style for you?

(In the future, we might consider making it do other things, too, like optionally escaping cell content if it contained any text that might be accidentally interpreted as Markdown format.)

(See also #106)

@nanobowers
Copy link
Contributor

@nateberkopec I think this can be closed - fixed as part of #113

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

3 participants