Render Markdown pipe tables as databse-styled terminal output inside <pre> blocks for Jekyll.
Install via RubyGems:
gem install jekyll-database-tablesOr add it to your Gemfile:
gem 'jekyll-database-tables'Then enable the plugin in _config.yml:
plugins:
- jekyll-database-tablesWrite a standard GFM pipe table in any page or document:
| Name | Age |
|-------|-----|
| Alice | 30 |
| Bob | 25 |The plugin replaces it with a <pre class="[db]-table"> block during the build:
Name | Age
------+----
Alice | 30
Bob | 25Content inside fenced code blocks is never processed, so example tables in documentation stay intact.
All options go under the jekyll_database_tables key in _config.yml:
jekyll_database_tables:
formatter: psql- Default (
psql): PostgreSQL-styled terminal output with space-padded columns separated by|and a-+-divider.
Custom formatters can also be provided (see Development).
git clone https://github.com/gdiasag/jekyll-database-tables
cd jekyll-database-tables
nix develop
rake testStarting a shell with the build environment provided in flake.nix provides you with Ruby, Bundler, and all gem dependencies pinned to exact versions from the lock file, so no bundle install needed. Gem executables (e.g. rake and rubocop) are on PATH directly.
Requires Ruby v3.3+ and Bundler v2.7+.
git clone https://github.com/gdiasag/jekyll-database-tables
cd jekyll-database-tables
bundle install
bundle exec rake testCreate a subclass of Jekyll::DatabaseTables::Formatter implementing #render, #format_row, and #separator. Then register it in Jekyll::DatabaseTables::Converter#formatter_instance:
class CustomFormatter < Jekyll::DatabaseTables::Formatter
include Formatter::Helpers
def render(table, title: nil)
# ...
end
def format_row(cells, widths)
# ...
end
def separator(widths)
# ...
end
endUsers select it via _config.yml:
jekyll_database_tables:
formatter: custom