rehype-responsive-tables
TypeScript icon, indicating that this package has built-in type declarations

2.0.14 • Public • Published

rehype-responsive-tables

Rehype plugin to stack the first column cells above their rows.

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence playground

Install

This package is not pure ESM, you can require it.

npm i rehype-responsive-tables

Quick Take

import { strict as assert } from "assert";
import { rehype } from "rehype";
import rehypeFormat from "rehype-format";
import rehypeResponsiveTables from "rehype-responsive-tables";

let input = `
<table>
  <tbody>
    <tr>
      <td>a</td>
      <td>b</td>
      <td>c</td>
    </tr>
  </tbody>
</table>
`;

let intended = `
<table class="rrt-table">
  <tbody>
    <tr class="rrt-new-tr">
      <td class="rrt-del-td"></td>
      <td colspan="2"><span class="rrt-new-tr__span-top">a</span></td>
    </tr>
    <tr>
      <td class="rrt-del-td">a</td>
      <td>b</td>
      <td>c</td>
    </tr>
  </tbody>
</table>
`;

assert.equal(
  rehype()
    .data("settings", { fragment: true })
    .use(rehypeResponsiveTables, {
      tableClassName: "rrt-table",
    })
    .use(rehypeFormat)
    .processSync(input)
    .toString(),
  intended,
);

Documentation

Please visit codsen.com for a full description of the API. Also, try the GUI playground.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2024 Roy Revelt and other contributors.

ok codsen star

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.14
    2
    • latest

Version History

Package Sidebar

Install

npm i rehype-responsive-tables

Weekly Downloads

3

Version

2.0.14

License

MIT

Unpacked Size

31.6 kB

Total Files

7

Last publish

Collaborators

  • royston