Transform deprecated styling attributes on HAST table cells to inline styles.
If you use remark to process Markdown as GitHub Flavored Markdown, you may find that your table cell elements end up with
align on these elements was deprecated in HTML5: the suggestion is to use a
style attribute that sets
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
(remark-react had to confront this issue.)
This simple utility transforms the following deprecated styling attributes on
<tr> elements to equivalent inline styles:
npm install @mapbox/hast-util-table-cell-style
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.