File tree 4 files changed +41
-3
lines changed
4 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ const removedOptions = [
76
76
*/
77
77
export function createProcessor ( options ) {
78
78
const {
79
+ SourceMapGenerator,
79
80
development,
81
+ elementAttributeNameCase,
80
82
jsx,
81
83
format,
82
84
outputFormat,
@@ -85,9 +87,8 @@ export function createProcessor(options) {
85
87
rehypePlugins,
86
88
remarkPlugins,
87
89
remarkRehypeOptions,
88
- elementAttributeNameCase,
89
90
stylePropertyNameCase,
90
- SourceMapGenerator ,
91
+ tableCellAlignToStyle ,
91
92
...rest
92
93
} = options || { }
93
94
let index = - 1
@@ -136,7 +137,11 @@ export function createProcessor(options) {
136
137
}
137
138
138
139
pipeline
139
- . use ( rehypeRecma , { elementAttributeNameCase, stylePropertyNameCase} )
140
+ . use ( rehypeRecma , {
141
+ elementAttributeNameCase,
142
+ stylePropertyNameCase,
143
+ tableCellAlignToStyle
144
+ } )
140
145
. use ( recmaDocument , { ...rest , outputFormat} )
141
146
. use ( recmaJsxRewrite , {
142
147
development,
Original file line number Diff line number Diff line change 22
22
*
23
23
* This casing is used for hast elements, not for embedded MDX JSX nodes
24
24
* (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`).
25
28
*
26
29
* @typedef {'css' | 'dom' } StylePropertyNameCase
27
30
* 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'`).
751
751
This casing is used for hast elements, not for embedded MDX JSX nodes
752
752
(components that someone authored manually).
753
753
754
+ ###### ` options.tableCellAlignToStyle `
755
+
756
+ Turn obsolete ` align ` props on ` td ` and ` th ` into CSS ` style ` props (default:
757
+ ` true ` ).
758
+
754
759
###### Returns
755
760
756
761
` 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'
15
15
import React from 'react'
16
16
import { renderToStaticMarkup } from 'react-dom/server'
17
17
import rehypeRaw from 'rehype-raw'
18
+ import remarkGfm from 'remark-gfm'
18
19
import { SourceMapGenerator } from 'source-map'
19
20
import { VFile } from 'vfile'
20
21
import { run } from './context/run.js'
@@ -1302,6 +1303,30 @@ test('@mdx-js/mdx: compile (JSX)', async function (t) {
1302
1303
}
1303
1304
}
1304
1305
)
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
+ } )
1305
1330
} )
1306
1331
1307
1332
test ( '@mdx-js/mdx: createProcessor' , async function ( t ) {
You can’t perform that action at this time.
0 commit comments