GithubHelp home page GithubHelp logo

frenzycoms / hast-util-table-cell-style Goto Github PK

View Code? Open in Web Editor NEW

This project forked from revoltchat/hast-util-table-cell-style

0.0 0.0 0.0 593 KB

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

License: Other

JavaScript 100.00%

hast-util-table-cell-style's Introduction

@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.

hast-util-table-cell-style's People

Contributors

dependabot[bot] avatar davidtheclark avatar christianmurphy avatar insertish avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.