npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

markdown-it-multimd-table-ext

v4.2.32

Published

Multimarkdown table syntax plugin for markdown-it markdown parser

Downloads

203

Readme

This is a fork of RedBug312's markdown-it-multimd-table, used in the bebras toolchain.*

Below is the original README, slightly modified.

NPM version

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 is an extended Markdown spec. It defines clear rules for advanced Markdown table syntax, while being consistent with original pipe table; markdown-it is a popular Markdown parser in JavaScript and allows 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)
  • Vertical alignment
  • Overridden horizontal and vertical alignment cell by cell
  • More control on lines

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. Please pose an issue if there are weird results for sensible inputs.

Usage

// defaults
var md = require('markdown-it')()
            .use(require('markdown-it-multimd-table-ext'));

// full options list (equivalent to defaults)
var md = require('markdown-it')()
            .use(require('markdown-it-multimd-table-ext'), {
              multiline:  false,
              rowspan:    false,
              headerless: false,
              multibody:  true,
              autolabel:  true,
            });

md.render(/*...*/)

For a quick demo:

$ mkdir markdown-it-multimd-table-ext
$ cd markdown-it-multimd-table-ext
$ npm install markdown-it markdown-it-multimd-table-ext --prefix .
$ vim test.js

    var md = require('markdown-it')()
                .use(require('markdown-it-multimd-table-ext'));

    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:

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.

|   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:

Rowspan

^^ indicates cells being merged above. Feature contributed by pmccloghrylaing.

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:

Headerless

Table header can be eliminated.

|--|--|--|--|--|--|--|--|
|♜|  |♝|♛|♚|♝|♞|♜|
|  |♟|♟|♟|  |♟|♟|♟|
|♟|  |♞|  |  |  |  |  |
|  |♗|  |  |♟|  |  |  |
|  |  |  |  |♙|  |  |  |
|  |  |  |  |  |♘|  |  |
|♙|♙|♙|♙|  |♙|♙|♙|
|♖|♘|♗|♕|♔|  |  |♖|

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.

Vertical Alignment

Allows setting the vertical alignment of columns with syntax embedded in the separator row.

| Top   | Bottom | Default |
| ^---- | v----- | ------- |

This sets the vertical alignment of the first two column to top and bottom, respectively.

Overridden Alignment

At the beginning of a cell, you can write [<align>] to set the alignment of the cell. This overrides the default alignment of the column. Both the horizontal and vertical alignment can be set.

| Col 1     | Col 2      | Col 3        | Col 4       |
| --------- | ---------- | ------------ |------------ |
| [^] Top   | [v] Bottom | [=] Middle   | Content     |
| [:-] Left | [-:] Right | [:-:] Center | [-] Default |

When specifying both horizontal and vertical alignment, the horizontal alignment should be written first. The alignment specifiers can be separated by a comma or a space for better readability.

Line Control

Whereas a simple | separator indicates a cell boundary, a double vertical bar in the separator row asks for a line to be drawn.

This adds a left and and right border to the table:

| Col 1 | Col 2 | Col 3 |
‖ ----- | ----- | ----- ‖
| A     | B     | C     |

only has an effect in the separator row and otherwise acts as a normal cell boundary; this adds no line:

‖ Col 1 | Col 2 | Col 3 ‖
| ----- | ----- | ----- |
| A     | B     | C     |

Complementarily, horizontal lines can be inserted in the middle of a table by having a line with hyphens - instead of actual cell contents (column boundaries are also allowed):

‖ Col 1 | Col 2 | Col 3 ‖
| ----- | ----- | ----- |
| A     | B     | C     |
| ----- | ----- | ----- |
| D     | E     | F     |

Build/Contribute

Use make browserify. To publish your fork after updading the package name, use npm publish.

Credits

  • MultiMarkdown, Lightweight markup processor to produce HTML, LaTeX, and more.
  • markdown-it, Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed.

License

This software is licensed under the MIT license © RedBug312, jppellet