@mapbox/hast-util-table-cell-style
Advanced tools
Comparing version 0.1.1 to 0.1.2
# Changelog | ||
## 0.1.2 | ||
- We're ok with end users on Node v4. | ||
## 0.1.1 | ||
@@ -4,0 +8,0 @@ |
51
index.js
@@ -5,2 +5,9 @@ 'use strict'; | ||
const hastCssPropertyMap = { | ||
align: 'text-align', | ||
valign: 'vertical-align', | ||
height: 'height', | ||
width: 'width' | ||
}; | ||
module.exports = function tableCellStyle(node) { | ||
@@ -15,6 +22,10 @@ visit(node, 'element', visitor); | ||
} | ||
transformAlign(node); | ||
transformValign(node); | ||
transformHeight(node); | ||
transformWidth(node); | ||
Object.keys(hastCssPropertyMap).map(hastName => { | ||
if (node.properties[hastName] === undefined) { | ||
return; | ||
} | ||
const cssName = hastCssPropertyMap[hastName]; | ||
appendStyle(node, cssName, node.properties[hastName]); | ||
delete node.properties[hastName]; | ||
}); | ||
} | ||
@@ -33,33 +44,1 @@ | ||
} | ||
function transformAlign(node) { | ||
if (node.properties.align === undefined) { | ||
return; | ||
} | ||
appendStyle(node, 'text-align', node.properties.align); | ||
delete node.properties.align; | ||
} | ||
function transformValign(node) { | ||
if (node.properties.valign === undefined) { | ||
return; | ||
} | ||
appendStyle(node, 'vertical-align', node.properties.valign); | ||
delete node.properties.valign; | ||
} | ||
function transformHeight(node) { | ||
if (node.properties.height === undefined) { | ||
return; | ||
} | ||
appendStyle(node, 'height', node.properties.height); | ||
delete node.properties.height; | ||
} | ||
function transformWidth(node) { | ||
if (node.properties.width === undefined) { | ||
return; | ||
} | ||
appendStyle(node, 'width', node.properties.width); | ||
delete node.properties.width; | ||
} |
{ | ||
"name": "@mapbox/hast-util-table-cell-style", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Transform deprecated styling attributes on HAST table cells to inline styles", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=4" | ||
}, | ||
@@ -36,0 +36,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13899
207