0.0
No release in over a year
This library generate it easy to create Markdown table like CSV library.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

MarkdownTable

This library generate it easy to create Markdown table like CSV library.

Installation

Add this line to your application's Gemfile:

gem 'markdown_table'

And then execute:

$ bundle

Usage

MarkdownTable.generate(header: %w[header1 header2 header3 header4]) do |table|
    table << %w[row1_1 row1_2 row1_3 row1_4]
    table << %w[row2_1 row2_2 row2_3 row2_4]
end

Output:

header1 header2 header3 header4
row1_1 row1_2 row1_3 row1_4
row2_1 row2_2 row2_3 row2_4
|header1|header2|header3|header4|
|-|-|-|-|
|row1_1|row1_2|row1_3|row1_4|
|row2_1|row2_2|row2_3|row2_4|

Set align option

MarkdownTable.generate(header: %w[header1 header2 header3 header4], align: %w[normal center left right]) do |table|
    table << %w[row1_1 row1_2 row1_3 row1_4]
    table << %w[row2_1 row2_2 row2_3 row2_4]
end

Output:

header1 header2 header3 header4
row1_1 row1_2 row1_3 row1_4
row2_1 row2_2 row2_3 row2_4
|header1|header2|header3|header4|
|-|:-:|:-|-:|
|row1_1|row1_2|row1_3|row1_4|
|row2_1|row2_2|row2_3|row2_4|

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kouppu/markdown_table. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the MarkdownTable project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.