markdown-to-jsx
Advanced tools
Comparing version 1.0.1 to 1.1.0
# markdown-to-jsx | ||
## Changelog | ||
### 1.1.0 (December 8, 2015) | ||
- Implement GFM table per-column alignment (d2ab598eaa7b2effc21befc93024ae4eecd1b3d9) | ||
### 1.0.1 (December 7, 2015) | ||
@@ -5,0 +9,0 @@ |
@@ -129,5 +129,6 @@ 'use strict'; | ||
case 'table': | ||
case 'tableCell': | ||
case 'th': | ||
return _extends({}, props, { | ||
style: { align: ast.align } | ||
style: { textAlign: ast.align } | ||
}); | ||
@@ -139,2 +140,22 @@ } | ||
function seekCellsAndAlignThemIfNecessary(root, alignmentValues) { | ||
var mapper = function mapper(child, index) { | ||
if (child.type === 'tableCell') { | ||
return _extends({}, child, { | ||
align: alignmentValues[index] | ||
}); | ||
} else if (Array.isArray(child.children) && child.children.length) { | ||
return child.children.map(mapper); | ||
} | ||
return child; | ||
}; | ||
if (Array.isArray(root.children) && root.children.length) { | ||
root.children = root.children.map(mapper); | ||
} | ||
return root; | ||
} | ||
function astToJSX(ast, index) { | ||
@@ -184,7 +205,7 @@ /* `this` is the dictionary of definitions */ | ||
if (child.type === 'tableHeader') { | ||
children.unshift(child); | ||
children.unshift(seekCellsAndAlignThemIfNecessary(child, ast.align)); | ||
} else if (child.type === 'tableRow') { | ||
tbody.children.push(child); | ||
tbody.children.push(seekCellsAndAlignThemIfNecessary(child, ast.align)); | ||
} else if (child.type === 'tableFooter') { | ||
children.push(child); | ||
children.push(seekCellsAndAlignThemIfNecessary(child, ast.align)); | ||
} | ||
@@ -191,0 +212,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"keywords": [ | ||
@@ -53,5 +53,6 @@ "markdown", | ||
"scripts": { | ||
"prepublish": "babel index.js --out-file index.es5.js", | ||
"prepublish": "npm run es5", | ||
"es5": "babel index.js --out-file index.es5.js", | ||
"test": "jest --verbose" | ||
} | ||
} |
# markdown to jsx converter | ||
![build status](https://api.travis-ci.org/yaycmyk/markdown-to-jsx.svg) | ||
Enables the safe parsing of markdown into proper React JSX objects, so you don't need to use a pattern like `dangerouslySetInnerHTML` and potentially open your application up to security issues. | ||
@@ -40,7 +42,4 @@ | ||
- mdast does not currently have support for column-specific alignment in GFM tables - | ||
[Bug Ticket](https://github.com/wooorm/mdast/issues/105) | ||
- mdast incorrectly parses footnote definitions with only one word - [Bug Ticket](https://github.com/wooorm/mdast/issues/106) | ||
MIT |
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
13523
247
45