yamltabl
v2.0.0
Published
Yamltabl lets you define tables in YAML using a predictable schema — and render to Markdown or HTML.
Maintainers
Readme
Yamltabl
Yamltabl lets you define tables in YAML using a predictable schema — and render to Markdown or HTML.
Perfect for everything-as-code documentation and static sites — without the messiness of raw Markdown or HTML tables.
Quick Example
What it looks like in Yamltabl:
yamltabl: 2.0.0
columns:
- haiku: Haiku Title
- line1: Line 1
- line2: Line 2
- line3: Line 3
row1:
haiku: “The Old Pond” by Matsuo Bashō
line1: An old silent pond
line2: A frog jumps into the pond —
line3: Splash! Silence again.
row2:
haiku: “A World of Dew” by Kobayashi Issa
line1: A world of dew,
line2: And within every dewdrop
line3: A world of struggle.Yamltabl converts the YAML above into a Markdown-compatible table:
<table>
<thead>
<tr>
<th id="haiku">Haiku Title</th>
<th id="line1">Line 1</th>
<th id="line2">Line 2</th>
<th id="line3">Line 3</th>
</tr>
</thead>
<tbody>
<tr id="haiku">
<td>“The Old Pond” by Matsuo Bashō</td>
<td>“A World of Dew” by Kobayashi Issa</td>
</tr>
<tr id="line1">
<td>An old silent pond</td>
<td>A world of dew,</td>
</tr>
<tr id="line2">
<td>A frog jumps into the pond —</td>
<td>And within every dewdrop</td>
</tr>
<tr id="line3">
<td>Splash! Silence again.</td>
<td>A world of struggle.</td>
</tr>
</tbody>
</table>👉 See the full schema specification for a breakdown of each section and more.
Usage and Installation
As a CLI tool
npx yamltabl generate html -i path/to/table.yaml -o path/to/destination/table.html
npx yamltabl generate md -i path/to/table.yaml -o path/to/destination/table.mdAs a library
npm install yamltablor
pnpm install yamltablIn your code:
import { renderHtml, renderMd } from 'yamltabl';
const yamlString = `
yamltabl: 2.0.0
columns:
- column1: Column 1
- column2: Column 2
- column3: Column 3
row1:
column1: Cell A
column2: Cell B
column3: >
<ul>
<li> list item 1
<li> list item 2
<li> list item 3
</ul>
`;
const htmlString = await renderHtml(yamlString);
console.log(htmlString);
const mdString = await renderMd(yamlString);
console.log(mdString);👉 Compare with other table authoring formats in this comparison guide.
