You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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
consttableCellStyle=require('@mapbox/hast-util-table-cell-style');// Use rehype to get an AST.consttransformed=tableCellStyle(ast);