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

rehype-extended-table

v0.1.3

Published

Rehype plugin to support table syntax allowing colspan / rowspan

Downloads

1,739

Readme

rehype-extended-table

Rehype plugin to support table syntax allowing colspan / rowspan.

npm github node

Feature

| Head 1 | Head 2 | Head 3 | Head 4 | Head 5 |
| ------ | ------ | ------ | ------ | ------ |
| >      | (2x1)  | Cell   | Cell   | Cell   |
| (1x3)  | >      | (2x2)  | >      | (2x2)  |
| ^      | >      | ^      | Cell   | Cell   |
| ^      | >      | >      | (3x1)  | Cell   |

↓↓

<table>
  <thead>
    <tr>
      <th>Head 1</th>
      <th>Head 2</th>
      <th>Head 3</th>
      <th>Head 4</th>
      <th>Head 5</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td colspan="2">(2x1)</td>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr>
      <td rowspan="3">(1x3)</td>
      <td colspan="2" rowspan="2">(2x2)</td>
      <td colspan="2">(2x2)</td>
    </tr>
    <tr>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr>
      <td colspan="3">(3x1)</td>
      <td>Cell</td>
    </tr>
  </tbody>
</table>

Installation

npm install rehype-extended-table --save-dev

Usage

import { rehypeExtendedTable } from 'rehype-extended-table';
import rehypeStringify from 'rehype-stringify';
import remarkGFM from 'remark-gfm';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
import { unified } from 'unified';

unified()
  .use(remarkParse)
  .use(remarkGFM)
  .use(remarkRehype)
  .use(rehypeExtendedTable)
  .use(rehypeStringify)
  .process(markdown);

Options

options.mergeTo

  • enum: ['right', 'left']
  • default: 'right'
  • description: Direction of table merge columns, using right is same as remark-extended-table, using left is same as Excel.

When using left, Write:

| Head 1 | Head 2 | Head 3 | Head 4 | Head 4 |
| :----: | :----: | :----: | :----: | :----: |
| (2x1)  |   <    |  Cell  |  Cell  |  Cell  |
| (1x3)  | (2x2)  |   <    | (2x2)  |   <    |
|   ^    |   ^    |   <    |  Cell  |  Cell  |
|   ^    | (3x1)  |   <    |   <    |  Cell  |

Tips

Why do I need this plugin?

remark-extended-table is good, but it wiil overrides remark-gfm behaviors, and have to inject handlers to remark-rehype:

import rehypeStringify from 'rehype-stringify';
import {
  extendedTableHandlers,
  remarkExtendedTable
} from 'remark-extended-table';
import remarkGfm from 'remark-gfm';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
import { unified } from 'unified';

unified()
  .use(remarkParse)
  .use(remarkGfm)
  .use(remarkExtendedTable)
  .use(remarkRehype, null, {
    handlers: {
      ...extendedTableHandlers
    }
  })
  .use(rehypeStringify)
  .process(markdown);

Some times we can't do that, you can use this plugin instead.

For example, in Docusaurus projects:

// docusaurus.config.mjs
import { rehypeExtendedTable } from 'rehype-extended-table';

export default {
  presets: [
    [
      'classic',
      {
        docs: {
          rehypePlugins: [
            [
              rehypeExtendedTable,
              {
                // ...options here
              }
            ]
          ]
        }
      }
    ]
  ]
};

Different with rehype-table-merge

  • rehype-extended-table support MDX props name by default.
  • rehype-extended-table can handle complex merge case without bug
  • support options.mergeTo

Related