https://github.com/redbug312/markdown-it-multimd-table
Multimarkdown table syntax plugin for markdown-it markdown parser
https://github.com/redbug312/markdown-it-multimd-table
markdown markdown-it-plugin multimarkdown table
Last synced: 2 months ago
JSON representation
Multimarkdown table syntax plugin for markdown-it markdown parser
- Host: GitHub
- URL: https://github.com/redbug312/markdown-it-multimd-table
- Owner: redbug312
- License: mit
- Created: 2017-08-12T16:59:53.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2026-01-21T23:24:59.000Z (3 months ago)
- Last Synced: 2026-01-22T03:52:46.379Z (3 months ago)
- Topics: markdown, markdown-it-plugin, multimarkdown, table
- Language: JavaScript
- Homepage:
- Size: 769 KB
- Stars: 154
- Watchers: 4
- Forks: 39
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/redbug312/markdown-it-multimd-table/actions)
[](https://www.npmjs.org/package/markdown-it-multimd-table)
[](https://coveralls.io/github/redbug312/markdown-it-multimd-table?branch=master)
MultiMarkdown table syntax plugin for markdown-it markdown parser
## Intro
Markdown specs defines only the basics for tables. When users want common
features like `colspan`, they must fallback to raw HTML. And writing tables in
HTML is truly *lengthy and troublesome*.
This plugin extends markdown-it with MultiMarkdown table syntax.
[MultiMarkdown][mmd6] is an extended Markdown spec. It defines clear rules for
advanced Markdown table syntax, while being consistent with original pipe
table; [markdown-it][mdit] is a popular Markdown parser in JavaScript and
allows plugins extending itself.
[mmd6]: https://fletcher.github.io/MultiMarkdown-6/
[mdit]: https://markdown-it.github.io/
The features are provided:
- Cell spans over columns
- Cell spans over rows (optional)
- Divide rows into sections
- Multiple table headers
- Table caption
- Block-level elements such as lists, codes... (optional)
- Omitted table header (optional)
Noted that the plugin is not a re-written of MultiMarkdown. This plugin will
behave differently from the official compiler, but doing its best to obey rules
defined in [MultiMarkdown User's Guide][mmd6-table]. Please pose an issue if
there are weird results for sensible inputs.
[mmd6-table]: https://fletcher.github.io/MultiMarkdown-6/syntax/tables.html
## Usage
```javascript
// defaults
var md = require('markdown-it')()
.use(require('markdown-it-multimd-table'));
// full options list (equivalent to defaults)
var md = require('markdown-it')()
.use(require('markdown-it-multimd-table'), {
multiline: false,
rowspan: false,
headerless: false,
multibody: true,
autolabel: true,
});
md.render(/*...*/)
```
For a quick demo:
```javascript
$ mkdir markdown-it-multimd-table
$ cd markdown-it-multimd-table
$ npm install markdown-it markdown-it-multimd-table --prefix .
$ vim test.js
var md = require('markdown-it')()
.use(require('markdown-it-multimd-table'));
const exampleTable =
"| | Grouping || \n" +
"First Header | Second Header | Third Header | \n" +
" ------------ | :-----------: | -----------: | \n" +
"Content | *Long Cell* || \n" +
"Content | **Cell** | Cell | \n" +
" \n" +
"New section | More | Data | \n" +
"And more | With an escaped '\\|' || \n" +
"[Prototype table] \n";
console.log(md.render(exampleTable));
$ node test.js > test.html
$ firefox test.html
```
Here's the table expected on browser:
Grouping
First Header
Second Header
Third Header
Content
Long Cell
Content
Cell
Cell
New section
More
Data
And more
With an escaped '|'
Prototype table
Noted that GitHub filters out `style` property, so the example uses `align` the
obsolete one. However it outputs `style="text-align: ..."` in actual.
## Options
### Multiline
Backslash at end merges with line content below.
Feature contributed by [Lucas-C](https://github.com/Lucas-C).
```markdown
| Markdown | Rendered HTML |
|--------------|---------------|
| *Italic* | *Italic* | \
| | |
| - Item 1 | - Item 1 | \
| - Item 2 | - Item 2 |
| ```python | ```python \
| .1 + .2 | .1 + .2 \
| ``` | ``` |
```
This is parsed below when the option enabled:
Markdown
Rendered HTML
*Italic*
Italic
- Item 1
- Item 2
- Item 1
- Item 2
```python
.1 + .2
```
.1 + .2
### Rowspan
`^^` indicates cells being merged above.
Feature contributed by [pmccloghrylaing](https://github.com/pmccloghrylaing).
```markdown
Stage | Direct Products | ATP Yields
----: | --------------: | ---------:
Glycolysis | 2 ATP ||
^^ | 2 NADH | 3--5 ATP |
Pyruvaye oxidation | 2 NADH | 5 ATP |
Citric acid cycle | 2 ATP ||
^^ | 6 NADH | 15 ATP |
^^ | 2 FADH2 | 3 ATP |
**30--32** ATP |||
[Net ATP yields per hexose]
```
This is parsed below when the option enabled:
Net ATP yields per hexose
Stage
Direct Products
ATP Yields
Glycolysis
2 ATP
2 NADH
3–5 ATP
Pyruvaye oxidation
2 NADH
5 ATP
Citric acid cycle
2 ATP
6 NADH
15 ATP
2 FADH2
3 ATP
30–32 ATP
### Headerless
Table header can be eliminated.
```markdown
|--|--|--|--|--|--|--|--|
|♜| |♝|♛|♚|♝|♞|♜|
| |♟|♟|♟| |♟|♟|♟|
|♟| |♞| | | | | |
| |♗| | |♟| | | |
| | | | |♙| | | |
| | | | | |♘| | |
|♙|♙|♙|♙| |♙|♙|♙|
|♖|♘|♗|♕|♔| | |♖|
```
This is parsed below when the option enabled:
♜
♝
♛
♚
♝
♞
♜
♟
♟
♟
♟
♟
♟
♟
♞
♗
♟
♙
♘
♙
♙
♙
♙
♙
♙
♙
♖
♘
♗
♕
♔
♖
### Multibody
An empty line separates consecutive table bodies. When disabled, an empty line
always cuts off the tables.
### Autolabel
Table `id` attribute follows the table caption if not labeled. When disabled,
caption without labels cannot generate the attribute.
## Credits
* [MultiMarkdown][mmd6], Lightweight
markup processor to produce HTML, LaTeX, and more.
* [markdown-it][mdit], Markdown parser, done right.
100% CommonMark support, extensions, syntax plugins & high speed.
## License
This software is licensed under the [MIT license][license] © RedBug312.
[license]: https://opensource.org/licenses/mit-license.php