micromark-extension-pipe-table
v0.2.0
Published
A micromark syntax extension that adds a pipe-based table syntax with support for vertical cells, multi-line content, and block-level elements.
Maintainers
Readme
micromark-extension-pipe-table
A micromark syntax extension that adds support for a custom pipe-based table syntax.
This package provides syntax only and is intended to be used with remark or other unified pipelines.
Vertical Cell Syntax
Pipe Table allows table cells to be written vertically, one per line, instead of being confined to a single row.
| a
| b
| cThis represents one table row with three cells.
Vertical layout makes tables easier to edit, reorder, and review in diffs, and enables multi-line and block-level content inside cells.
For the complete syntax specification, see:
docs/syntax.md
Install
npm install micromark-extension-pipe-tableUsage
import { micromark } from 'micromark'
import { pipeTable, pipeTableHtml } from 'micromark-extension-pipe-table'
const html = micromark('| a | b | c', {
extensions: [pipeTable()],
htmlExtensions: [pipeTableHtml()]
})
console.log(html)Options
pipeTableHtml({
/**
* Alignment class prefix.
* default: "cell-"
*/
classPrefix?: string
/**
* Use logical alignment classes (start / center / end)
* default: false
*/
useLogicalAlignment?: boolean
})- Alignment classes are applied to
<td>only:cell-leftcell-centercell-right
Notes
- Lines starting with
|(optionally preceded by up to 3 spaces) are treated as table rows. - Escaped pipes (
\|) are preserved as literal text. - This extension works with micromark alone.
If you want to convert pipe-table syntax into mdast or hast, use it together with the following packages:mdast-util-pipe-tablehast-util-pipe-table
Related Packages
mdast-util-pipe-tableConverts pipe-table tokens into mdast nodes and defines the canonical AST shape.hast-util-pipe-tableTransforms pipe-table mdast nodes into HTML (hast).remark-pipe-tableRemark plugin that wires all pipe-table extensions together.
License
MIT
