Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markdown-it-multimd-table

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-multimd-table

Multimarkdown table syntax plugin for markdown-it markdown parser

  • 3.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by165.44%
Maintainers
1
Weekly downloads
 
Created
Source

NPM version Build Status Coverage Status

MultiMarkdown table syntax plugin for markdown-it markdown parser

Intro

In general Markdown syntax, we have to write raw HTML tags when colspan attribute is needed. Luckily, I found that MultiMarkdown had defined complete and clear rules for advanced Markdown table syntax, and compatible to general Markdown table syntax.

So I extend the table parser in markdown-it to support MultiMarkdown table syntax. For now, the following features are provided:

  • Cells spanning multiple columns
  • Grouped table headers
  • Grouped table rows
  • Table captions
  • Lists in table cell (optional)
  • Line breaks in table cells (optional)

Noted that the plugin might behave differently from MultiMarkdown in some edge cases; since the plugin was developed to follow the rules in MultiMarkdown User's Guide.

Usage

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

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

To simply test this plugin, you can do these in terminal:

$ mkdir markdown-it-multimd-table
$ cd markdown-it-multimd-table
$ npm install 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

And you will see the rendered table in the browser:

Prototype table
Grouping
First HeaderSecond HeaderThird Header
ContentLong Cell
ContentCellCell
New sectionMoreData
And moreWith an escaped '|'

Multiple lines of row (optional)

Put backslashes to indicate line-breaks to allow the table rows being parsed in multiple rows. This feature is contributed by Lucas-C.

First header | Second header
-------------|---------------
List:        | More  \
- over       | data  \
- several    |       \
- lines      |

would be parsed as

First headerSecond header

List:

  • over
  • several
  • lines

More data

Here's how you can enable the feature.

var md = require('markdown-it')()
            .use(require('markdown-it-multimd-table'), {enableMultilineRows: true});

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.

Keywords

FAQs

Package last updated on 19 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc