File tree Expand file tree Collapse file tree 4 files changed +41
-3
lines changed Expand file tree Collapse file tree 4 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ const removedOptions = [
7676 */
7777export function createProcessor ( options ) {
7878 const {
79+ SourceMapGenerator,
7980 development,
81+ elementAttributeNameCase,
8082 jsx,
8183 format,
8284 outputFormat,
@@ -85,9 +87,8 @@ export function createProcessor(options) {
8587 rehypePlugins,
8688 remarkPlugins,
8789 remarkRehypeOptions,
88- elementAttributeNameCase,
8990 stylePropertyNameCase,
90- SourceMapGenerator ,
91+ tableCellAlignToStyle ,
9192 ...rest
9293 } = options || { }
9394 let index = - 1
@@ -136,7 +137,11 @@ export function createProcessor(options) {
136137 }
137138
138139 pipeline
139- . use ( rehypeRecma , { elementAttributeNameCase, stylePropertyNameCase} )
140+ . use ( rehypeRecma , {
141+ elementAttributeNameCase,
142+ stylePropertyNameCase,
143+ tableCellAlignToStyle
144+ } )
140145 . use ( recmaDocument , { ...rest , outputFormat} )
141146 . use ( recmaJsxRewrite , {
142147 development,
Original file line number Diff line number Diff line change 2222 *
2323 * This casing is used for hast elements, not for embedded MDX JSX nodes
2424 * (components that someone authored manually).
25+ * @property {boolean | null | undefined } [tableCellAlignToStyle=true]
26+ * Turn obsolete `align` props on `td` and `th` into CSS `style` props
27+ * (default: `true`).
2528 *
2629 * @typedef {'css' | 'dom' } StylePropertyNameCase
2730 * Casing to use for property names in `style` objects.
Original file line number Diff line number Diff line change @@ -751,6 +751,11 @@ default: `'dom'`).
751751This casing is used for hast elements, not for embedded MDX JSX nodes
752752(components that someone authored manually).
753753
754+ ###### ` options.tableCellAlignToStyle `
755+
756+ Turn obsolete ` align ` props on ` td ` and ` th ` into CSS ` style ` props (default:
757+ ` true ` ).
758+
754759###### Returns
755760
756761` Promise<VFile> ` — Promise that resolves to the compiled JS as a [ vfile] [ ] .
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {MDXProvider} from '@mdx-js/react'
1515import React from 'react'
1616import { renderToStaticMarkup } from 'react-dom/server'
1717import rehypeRaw from 'rehype-raw'
18+ import remarkGfm from 'remark-gfm'
1819import { SourceMapGenerator } from 'source-map'
1920import { VFile } from 'vfile'
2021import { run } from './context/run.js'
@@ -1302,6 +1303,30 @@ test('@mdx-js/mdx: compile (JSX)', async function (t) {
13021303 }
13031304 }
13041305 )
1306+
1307+ await t . test ( 'should support `tableCellAlignToStyle`' , async function ( ) {
1308+ assert . match (
1309+ String (
1310+ await compile ( '| a |\n| :- |' , {
1311+ remarkPlugins : [ remarkGfm ] ,
1312+ tableCellAlignToStyle : true ,
1313+ jsx : true
1314+ } )
1315+ ) ,
1316+ / t e x t A l i g n : " l e f t " /
1317+ )
1318+
1319+ assert . match (
1320+ String (
1321+ await compile ( '| a |\n| :- |' , {
1322+ remarkPlugins : [ remarkGfm ] ,
1323+ tableCellAlignToStyle : false ,
1324+ jsx : true
1325+ } )
1326+ ) ,
1327+ / a l i g n = " l e f t " /
1328+ )
1329+ } )
13051330} )
13061331
13071332test ( '@mdx-js/mdx: createProcessor' , async function ( t ) {
You can’t perform that action at this time.
0 commit comments