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

@felisdiligens/md-table-tools

v0.1.3

Published

MultiMarkdown table tools

Downloads

173

Readme

Warning
Work in progress. API may change in the future, bugs may rear their ugly head...
Use with care! If in doubt, ask me. :)

MultiMarkdown table tools

npm link npm downloads npm version MIT license

Screenshot of web demo

Features

  • Parsing MultiMarkdown, GitHub-flavored Markdown, HTML, or CSV tables into intermediary
  • Converting intermediary back to MultiMarkdown, GitHub-flavored Markdown, HTML, or CSV tables
  • Formatting or minifying MultiMarkdown or GFM tables
  • Manipulating parsed/intermediary tables (⚠️ possibly buggy, please run Table.update() after making any changes), e.g.
    • by adding, deleting, or moving rows/columns
    • by changing the content of table cells
    • by merging or splitting table cells
    • by changing the text alignment within a column
    • etc.

Module

This project gets packaged as CommonJS and ES module. Types are generated as well.

To install, run

npm i @felisdiligens/md-table-tools

Usage / Examples

Web demo

A web demo (see screenshot above) can be accessed here.

The source code is under ./demo.

CLI demo

$ npm run demo
import { MultiMarkdownTableParser } from "@felisdiligens/md-table-tools";
import { HTMLTableRenderer } from "@felisdiligens/md-table-tools";

const mdParser = new MultiMarkdownTableParser();
const htmlRenderer = new HTMLTableRenderer();

var mdTable = `
| Example | table  |
|---------|--------|
| Hello   | world! |
`;

// Parse markdown to intermediary:
var intermediaryTable = mdParser.parse(mdTable);

// Make some changes:
intermediaryTable.getCell(1, 1).setText("everyone!");
intermediaryTable.update();

// Render as HTML:
var htmlTable = htmlRenderer.render(intermediaryTable);

/* Output:
<table>
  <thead>
    <tr>
      <th>Example</th>
      <th>table</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Hello</td>
      <td>everyone!</td>       <--- Changed!
    </tr>
  </tbody>
</table>
*/

Projects

See my Joplin plugin as an example for usage.

Docs

You can access the documentation here: ./docs/modules.md.
Or click on one of the classes below:

Development

Building

$ git clone https://github.com/FelisDiligens/md-table-tools.git
$ cd md-table-tools
$ npm install
$ npm run build

Testing

$ npm run test

MultiMarkdown Syntax

This module mostly follows the MultiMarkdown specs: https://fletcher.github.io/MultiMarkdown-6/syntax/tables.html

With a few exceptions:

  • You can merge cells vertically by writing ^^ into a cell.
  • You can use \ to join rows together.

Differences to tables in GitHub-flavored Markdown (and similar variants)

GitHub-flavored Markdown tables (and similar variants) are fully supported, with these additional features:

  • You can merge cells horizontally by adding additional pipes (|) at the end of the cell.
  • You can merge cells vertically by writing ^^ into a cell.
  • You can merge the row below by writing \ at the end of a row.
  • You can add a caption above or below to the table. Captions can optionally have labels.
  • You can have a header with multiple rows.
  • You can omit the header.
  • You can divide the table into multiple sections by adding a single empty line in-between rows.

Built with...