@mapbox/hast-util-table-cell-style
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/mapbox__hast-util-table-cell-style package

0.2.1 • Public • Published

@mapbox/hast-util-table-cell-style

Build Status

Transform deprecated styling attributes on HAST table cells to inline styles.

About

HAST is the abstract syntax (AST) tree representing HTML that rehype uses.

If you use remark to process Markdown as GitHub Flavored Markdown, you may find that your table cell elements end up with align attributes. However, align on these elements was deprecated in HTML5: the suggestion is to use a style attribute that sets text-align, instead.

This matters because more recent syntaxes might altogether ignore align or other deprecated styling attributes. React, for example, does not support align attributes; so if you try to transform Markdown to React elements, you'll lose your align values. (remark-react had to confront this issue.)

This simple utility transforms the following deprecated styling attributes on <td>, <th>, and <tr> elements to equivalent inline styles:

  • align
  • valign
  • width
  • height

Installation

npm install @mapbox/hast-util-table-cell-style

Usage

const tableCellStyle = require('@mapbox/hast-util-table-cell-style');

// Use rehype to get an AST.
const transformed = tableCellStyle(ast);

Mutates the HAST AST you pass in, and returns it.

Package Sidebar

Install

npm i @mapbox/hast-util-table-cell-style

Weekly Downloads

158,378

Version

0.2.1

License

BSD-2-Clause

Unpacked Size

14.3 kB

Total Files

10

Last publish

Collaborators

  • mbx-npm-ci-production
  • mbx-npm-ci-staging
  • mbx-npm-advanced-actions-production
  • mbx-npm-advanced-actions-staging
  • mbx-npm-09-production
  • mbx-npm-08-production
  • mbx-npm-07-production
  • mbx-npm-06-production
  • mbx-npm-05-production
  • mbx-npm-04-production
  • mbx-npm-03-production
  • mbx-npm-02-production
  • mbx-npm-01-production
  • mbx-npm-02-staging
  • mapbox-npm-01
  • mapbox-npm-02
  • mapbox-npm-07
  • mapbox-npm-03
  • mapbox-npm-04
  • mapbox-npm-09
  • mapbox-npm-05
  • mapbox-npm-06
  • mapbox-npm-08
  • mapbox-npm-advanced-actions
  • mapbox-npm-ci
  • mapbox-npm
  • mapbox-admin
  • mapbox-machine-user