- Notifications
You must be signed in to change notification settings - Fork38
Multimarkdown table syntax plugin for markdown-it markdown parser
License
redbug312/markdown-it-multimd-table
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
MultiMarkdown table syntax plugin for markdown-it markdown parser
Markdown specs defines only the basics for tables. When users want commonfeatures likecolspan, they must fallback to raw HTML. And writing tables inHTML is trulylengthy and troublesome.
This plugin extends markdown-it with MultiMarkdown table syntax.MultiMarkdown is an extended Markdown spec. It defines clear rules foradvanced Markdown table syntax, while being consistent with original pipetable;markdown-it is a popular Markdown parser in JavaScript andallows plugins extending itself.
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 willbehave differently from the official compiler, but doing its best to obey rulesdefined inMultiMarkdown User's Guide. Please pose an issue ifthere are weird results for sensible inputs.
// defaultsvarmd=require('markdown-it')().use(require('markdown-it-multimd-table'));// full options list (equivalent to defaults)varmd=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:
$mkdirmarkdown-it-multimd-table$cdmarkdown-it-multimd-table$npminstallmarkdown-itmarkdown-it-multimd-table--prefix.$vimtest.jsvarmd=require('markdown-it')().use(require('markdown-it-multimd-table'));constexampleTable="| | 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));$nodetest.js>test.html$firefoxtest.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 '|' | |
Noted that GitHub filters outstyle property, so the example usesalign theobsolete one. However it outputsstyle="text-align: ..." in actual.
Backslash at end merges with line content below.
Feature contributed byLucas-C.
| 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 |
|
|
| |
^^ indicates cells being merged above.
Feature contributed bypmccloghrylaing.
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:
| 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 | ||
Table header can be eliminated.
|--|--|--|--|--|--|--|--||♜||♝|♛|♚|♝|♞|♜|||♟|♟|♟||♟|♟|♟||♟||♞||||||||♗|||♟|||||||||♙||||||||||♘||||♙|♙|♙|♙||♙|♙|♙||♖|♘|♗|♕|♔|||♖|
This is parsed below when the option enabled:
| ♜ | ♝ | ♛ | ♚ | ♝ | ♞ | ♜ | |
| ♟ | ♟ | ♟ | ♟ | ♟ | ♟ | ||
| ♟ | ♞ | ||||||
| ♗ | ♟ | ||||||
| ♙ | |||||||
| ♘ | |||||||
| ♙ | ♙ | ♙ | ♙ | ♙ | ♙ | ♙ | |
| ♖ | ♘ | ♗ | ♕ | ♔ | ♖ |
An empty line separates consecutive table bodies. When disabled, an empty linealways cuts off the tables.
Tableid attribute follows the table caption if not labeled. When disabled,caption without labels cannot generate the attribute.
- MultiMarkdown, Lightweightmarkup processor to produce HTML, LaTeX, and more.
- markdown-it, Markdown parser, done right.100% CommonMark support, extensions, syntax plugins & high speed.
This software is licensed under theMIT license © RedBug312.
About
Multimarkdown table syntax plugin for markdown-it markdown parser
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors11
Uh oh!
There was an error while loading.Please reload this page.