Class: DocsKit::MarkdownExport::Table
- Inherits:
-
Object
- Object
- DocsKit::MarkdownExport::Table
- Defined in:
- lib/docs_kit/markdown_export/table.rb
Overview
A GFM pipe table. The first row (thead, or the first row if there's no thead) is the header; a separator row follows; the rest are body rows. Cell content is inline Markdown with pipes escaped so they don't break the table.
Instance Method Summary collapse
-
#initialize(export) ⇒ Table
constructor
A new instance of Table.
- #render(node) ⇒ Object
Constructor Details
Instance Method Details
#render(node) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/docs_kit/markdown_export/table.rb', line 13 def render(node) rows = rows(node) return "" if rows.empty? width = rows.map(&:length).max header, *body = pad(rows, width) lines = [row(header), separator(width)] lines.concat(body.map { |cells| row(cells) }) lines.join("\n") end |