{"_id":"@benjc/rehype-enhanced-tables","name":"@benjc/rehype-enhanced-tables","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.1":{"author":{"name":"Benjamin Charity","email":"ben.charity@hey.com","url":"https://www.benjamincharity.com/"},"bugs":{"url":"https://github.com/benjamincharity/rehype-enhanced-tables/issues"},"dependencies":{"hast-util-has-property":"3.0.0","hast-util-is-element":"3.0.0","rehype":"^13.0.0","unified":"^11.0.0","unist-util-remove":"4.0.0","unist-util-visit":"^5.0.0"},"description":"A Rehype plugin that modifies HTML tables, with support for caption, footer, custom classes, scroll-wrappers, and scopes.","devDependencies":{"@trivago/prettier-plugin-sort-imports":"^4.3.0","@types/hast":"^3.0.4","@types/node":"^20.11.16","@vitest/coverage-v8":"^1.2.2","hast-util-select":"6.0.2","hast-util-to-html":"^9.0.0","hastscript":"^9.0.0","prettier":"^3.2.4","rehype-minify-whitespace":"^6.0.0","rimraf":"^5.0.5","to-vfile":"^8.0.0","type-coverage":"^2.27.1","typecov":"~0.2.3","typescript":"^5.3.3","vite":"^5.0.12","vitest":"^1.2.2","xo":"~0.56.0"},"engines":{"node":">=18.0.0"},"homepage":"https://github.com/benjamincharity/rehype-enhanced-tables#readme","keywords":["rehype","rehype-plugin","unified","unified-plugin","html","images","figure"],"license":"MIT","main":"dist/index.js","module":"dist/index.js","name":"@benjc/rehype-enhanced-tables","repository":{"type":"git","url":"git+https://github.com/benjamincharity/rehype-enhanced-tables.git"},"scripts":{"build":"tsc","coverage":"vitest run --coverage","coverage:types":"type-coverage","format":"prettier --write .","lint":"xo --prettier","lint:fix":"xo --fix --prettier","prebuild":"rimraf dist","test":"vitest","typecheck":"tsc --noEmit"},"type":"module","typeCoverage":{"atLeast":97,"detail":true,"ignoreCatch":true,"strict":true},"types":"dist/index.d.ts","version":"0.1.1","_id":"@benjc/rehype-enhanced-tables@0.1.1","gitHead":"c5c8b63c99a1a2027d11547bac8e2e854c785a46","_nodeVersion":"20.11.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-4GlVQoQ5XBkBp5XXfMN6Ps3sN6y2Jvxo7NQD92LZiJ0y5ix0GvXejXvuoFD+WqQhBrKpbp0TPaZ17qZabHxGXg==","shasum":"e36416d8a55f0fcd6ea1fa8f1a1d22f6e17da56f","tarball":"https://registry.npmjs.org/@benjc/rehype-enhanced-tables/-/rehype-enhanced-tables-0.1.1.tgz","fileCount":9,"unpackedSize":15891,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@benjc%2frehype-enhanced-tables@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBjVJateikqzDJfvMvxY7oArj+b1SRsU38UwAIEgWWxgAiEA0XtC+j/m+05NErtmdsxNQe5Si48IR4eW28wTG5XbwjU="}]},"_npmUser":{"name":"benjamincharity","email":"ben.charity@hey.com"},"directories":{},"maintainers":[{"name":"benjamincharity","email":"ben.charity@hey.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rehype-enhanced-tables_0.1.1_1707600272640_0.5850734066699554"},"_hasShrinkwrap":false}},"time":{"created":"2024-02-10T21:24:32.523Z","0.1.1":"2024-02-10T21:24:32.807Z","modified":"2024-02-10T21:24:33.330Z"},"maintainers":[{"name":"benjamincharity","email":"ben.charity@hey.com"}],"description":"A Rehype plugin that modifies HTML tables, with support for caption, footer, custom classes, scroll-wrappers, and scopes.","homepage":"https://github.com/benjamincharity/rehype-enhanced-tables#readme","keywords":["rehype","rehype-plugin","unified","unified-plugin","html","images","figure"],"repository":{"type":"git","url":"git+https://github.com/benjamincharity/rehype-enhanced-tables.git"},"author":{"name":"Benjamin Charity","email":"ben.charity@hey.com","url":"https://www.benjamincharity.com/"},"bugs":{"url":"https://github.com/benjamincharity/rehype-enhanced-tables/issues"},"license":"MIT","readme":"# rehype-enhanced-tables\n\n![test workflow](https://github.com/benjamincharity/rehype-enhanced-tables/actions/workflows/test.yml/badge.svg)\n[![codecov](https://codecov.io/gh/benjamincharity/rehype-enhanced-tables/branch/main/graph/badge.svg?token=T3Z18P56LV)](https://codecov.io/gh/benjamincharity/rehype-enhanced-tables)\n![NPM Version](https://img.shields.io/npm/v/@benjc/rehype-enhanced-tables)\n\nA Rehype plugin that modifies HTML tables, with support for caption, footer, custom classes, scroll-wrappers, and scopes.\n\n## Install\n\n```\nnpm i -D @benjc/rehype-enhanced-tables\n```\n\n## Usage\n\n```typescript\nimport rehypeEnhancedTables from \"@benjc/rehype-enhanced-tables\";\nimport rehype from \"rehype\";\nimport rehypeParse from \"rehype-parse\";\nimport { unified } from \"unified\";\n\nconst tableStruct = `\n| heading | b  |  c |  d  |\n| -: | -: | -: | :-: |\n| cell 1 | cell 2 | 3 | 4 |\n`;\n\nunified()\n  .use(rehypeParse, { fragment: true })\n  .use(rehypeEnhancedTables)\n  .process(tableStruct);\n\n// Or with options:\nunified()\n  .use(rehypeParse, { fragment: true })\n  .use(rehypeEnhancedTables, {\n    disableWrapper: true,\n    classes: {\n      table: \"custom-class\",\n      cell: \"custom-cell\",\n      ...\n    },\n  })\n  .process(tableStruct);\n```\n\n### Input\n\n```html\n<table>\n  <thead>\n    <tr>\n      <th>One</th>\n      <th>Two</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>Cell 1</td>\n      <td>Cell 2</td>\n    </tr>\n    <tr>\n      <td>Cell 3</td>\n      <td>Cell 4</td>\n    </tr>\n  </tbody>\n</table>\n```\n\n### Output\n\n```html\n<div class=\"ret-table-wrapper\">\n  <table class=\"ret-table\">\n    <thead class=\"ret-table-thead\">\n      <tr class=\"ret-table-row\">\n        <th scope=\"col\" class=\"ret-table-th\">One</th>\n        <th scope=\"col\" class=\"ret-table-th\">Two</th>\n      </tr>\n    </thead>\n    <tbody class=\"ret-table-body\">\n      <tr class=\"ret-table-row\">\n        <td class=\"ret-table-cell\">Cell 1</td>\n        <td class=\"ret-table-cell\">Cell 2</td>\n      </tr>\n      <tr class=\"ret-table-row\">\n        <td class=\"ret-table-cell\">Cell 3</td>\n        <td class=\"ret-table-cell\">Cell 4</td>\n      </tr>\n    </tbody>\n  </table>\n</div>\n```\n\n## Options\n\nThe `rehype-enhanced-tables` plugin accepts an `options` object with the following properties:\n\n| Option           | Type                                         | Description                                                                                                                                                          |\n| ---------------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `disableWrapper` | `boolean`                                    | If set to `true`, the plugin will not wrap the table with a div.                                                                                                     |\n| `classes`        | `Partial<RehypeEnhancedTableElementClasses>` | An object that maps element types to class names. The keys can be any of the following: `caption`, `footer`, `table`, `tbody`, `td`, `th`, `thead`, `tr`, `wrapper`. |\n\nThese options can be passed to the `rehype-enhanced-tables` plugin as part of the `options` object. For example:\n\n```typescript\nimport rehypeEnhancedTables from \"./index\";\n\nrehypeEnhancedTables({\n  disableWrapper: true,\n  classes: {\n    caption: \"custom-caption\",\n    table: \"custom-table\",\n    tbody: \"custom-tbody\",\n    td: \"custom-td\",\n    tfoot: \"custom-tfoot\",\n    th: \"custom-th\",\n    thead: \"custom-thead\",\n    tr: \"custom-tr\",\n    wrapper: \"custom-wrapper\",\n  },\n});\n```\n\n## License\n\n[MIT][license] © [benjamincharity][author]\n\n[license]: license\n[author]: https://www.benjamincharity.com\n","readmeFilename":"README.md"}