Skip to content

Commit

Permalink
Merge pull request #13 from craftzdog/master
Browse files Browse the repository at this point in the history
fix(table): Use hast-util-table-cell-style to adjust align properties
rhysd authored Nov 19, 2018
2 parents fc9c48d + 407878d commit a0da718
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
/* Dependencies. */
var has = require('has');
var toH = require('hast-to-hyperscript');
var tableCellStyle = require('@mapbox/hast-util-table-cell-style');

/* Expose `rehype-react`. */
module.exports = rehype2react;
@@ -41,7 +42,7 @@ function rehype2react(options) {
}
}

return toH(h, node, settings.prefix);
return toH(h, tableCellStyle(node), settings.prefix);
}

/* Wrap `createElement` to pass components in. */
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
"rhysd <lin90162@yahoo.co.jp>"
],
"dependencies": {
"@mapbox/hast-util-table-cell-style": "^0.1.3",
"has": "^1.0.1",
"hast-to-hyperscript": "^5.0.0"
},
10 changes: 10 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -108,5 +108,15 @@ test('React ' + React.version, function (t) {
'should support components'
);

t.deepEqual(
processor.stringify(h('table', {}, [h('thead', h('th', {align: 'right'}))])),
React.createElement('table', {key: 'h-1'}, [
React.createElement('thead', {key: 'h-2'}, [
React.createElement('th', {style: {textAlign: 'right'}, key: 'h-3'}, undefined)
])
]),
'should transform an element with align property'
);

t.end();
});

0 comments on commit a0da718

Please sign in to comment.