Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-react

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-react - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

18

history.md

@@ -0,1 +1,11 @@

<a name="3.1.1"></a>
## [3.1.1](https://github.com/mapbox/remark-react/compare/v3.1.0...v3.1.1) (2017-03-07)
### Bug Fixes
* **output:** Remove unknown prop 'align' ([e0462f1](https://github.com/mapbox/remark-react/commit/e0462f1))
<!--lint disable no-multiple-toplevel-headings-->

@@ -5,9 +15,9 @@

* Adds `toHast` option that allows customization at the [mdast-util-to-hast](https://github.com/wooorm/mdast-util-to-hast#api)
level.
* Adds `toHast` option that allows customization at the [mdast-util-to-hast](https://github.com/wooorm/mdast-util-to-hast#api)
level.
# 3.0.2
* Fixes interpretation of the `sanitize` option, allowing users to pass
`false` to disable sanitization.
* Fixes interpretation of the `sanitize` option, allowing users to pass
`false` to disable sanitization.

@@ -14,0 +24,0 @@ # 2.1.0

'use strict';
/*
* Dependencies.
*/
module.exports = remarkReact;

@@ -10,6 +8,9 @@ var toHAST = require('mdast-util-to-hast');

var toH = require('hast-to-hyperscript');
var xtend = require('xtend');
var globalCreateElement;
try {
var globalCreateElement = require('react').createElement;
} catch (e) { }
globalCreateElement = require('react').createElement;
} catch (err) {}

@@ -34,71 +35,79 @@ var own = {}.hasOwnProperty;

*/
function plugin(processor, options) {
var settings = options || {};
var createElement = settings.createElement || globalCreateElement;
var components = settings.remarkReactComponents || {};
var clean = settings.sanitize !== false;
var scheme = clean && (typeof settings.sanitize !== 'boolean') ? settings.sanitize : null;
var toHastOptions = settings.toHast || {};
function remarkReact(options) {
var settings = options || {};
var createElement = settings.createElement || globalCreateElement;
var clean = settings.sanitize !== false;
var scheme = clean && (typeof settings.sanitize !== 'boolean') ? settings.sanitize : null;
var toHastOptions = settings.toHast || {};
var components = xtend({
td: createTableCellComponent('td'),
th: createTableCellComponent('th')
}, settings.remarkReactComponents);
/**
* Wrapper around `createElement` to pass
* components in.
*
* @param {string} name - Element name.
* @param {Object} props - Attributes.
* @return {ReactElement} - React element.
*/
function h(name, props, children) {
var component = own.call(components, name) ? components[name] : name;
this.Compiler = compile;
/*
* Currently, a warning is triggered by react for
* *any* white-space in tables. So we remove the
* pretty lines for now:
* https://github.com/facebook/react/pull/7081
*/
if (children && TABLE_ELEMENTS.indexOf(component) !== -1) {
children = children.filter(function (child) {
return child !== '\n';
});
}
/**
* Wrapper around `createElement` to pass
* components in.
*
* @param {string} name - Element name.
* @param {Object} props - Attributes.
* @return {ReactElement} - React element.
*/
function h(name, props, children) {
var component = own.call(components, name) ? components[name] : name;
return createElement(component, props, children);
/*
* Currently, a warning is triggered by react for
* *any* white-space in tables. So we remove the
* pretty lines for now:
* https://github.com/facebook/react/pull/7081
*/
if (children && TABLE_ELEMENTS.indexOf(component) !== -1) {
children = children.filter(function (child) {
return child !== '\n';
});
}
/**
* Extensible constructor.
*/
function Compiler() {}
return createElement(component, props, children);
}
/**
* Compile MDAST to React.
*
* @param {Node} node - MDAST node.
* @return {ReactElement} - React element.
*/
function compile(node) {
var hast = {
type: 'element',
tagName: 'div',
properties: {},
children: toHAST(node, toHastOptions).children
};
/**
* Compile MDAST to React.
*
* @param {Node} node - MDAST node.
* @return {ReactElement} - React element.
*/
function compile(node) {
var hast = {
type: 'element',
tagName: 'div',
properties: {},
children: toHAST(node, toHastOptions).children
};
if (clean) {
hast = sanitize(hast, scheme);
}
return toH(h, hast, settings.prefix);
if (clean) {
hast = sanitize(hast, scheme);
}
Compiler.prototype.compile = compile;
return toH(h, hast, settings.prefix);
}
processor.Compiler = Compiler;
/**
* Create a functional React component for a cell.
* We need this because GFM uses `align`, whereas React
* forbids that and wants `style.textAlign` instead.
*/
function createTableCellComponent(tagName) {
return TableCell;
function TableCell(props) {
const fixedProps = xtend(props, {
children: undefined,
style: {textAlign: props.align}
});
delete fixedProps.align;
return createElement(tagName, fixedProps, props.children);
}
}
}
/*
* Expose `plugin`.
*/
module.exports = plugin;
{
"name": "remark-react",
"description": "Compile Markdown to React with remark",
"version": "3.1.0",
"version": "3.1.1",
"author": {

@@ -21,17 +21,18 @@ "name": "Titus Wormer",

"hast-util-sanitize": "^1.0.0",
"mdast-util-to-hast": "^1.0.0"
"mdast-util-to-hast": "^2.0.0",
"standard-changelog": "^0.0.1",
"xtend": "^4.0.1"
},
"devDependencies": {
"commonmark.json": "^0.23.0",
"eslint": "^2.2.0",
"istanbul": "^0.4.2",
"jscs": "^3.0.0",
"jscs-jsdoc": "^2.0.0",
"remark": "^5.0.0",
"remark-cli": "^1.0.0",
"remark-github": "^5.0.0",
"remark-lint": "^4.0.0",
"remark-toc": "^3.0.0",
"mocha": "^2.4.5",
"vfile": "^1.3.1"
"cz-conventional-changelog": "^2.0.0",
"mocha": "^3.1.0",
"nyc": "^10.1.2",
"remark": "^7.0.0",
"remark-cli": "^3.0.0",
"remark-github": "^7.0.0",
"remark-preset-lint-consistent": "^2.0.0",
"remark-preset-lint-recommended": "^2.0.0",
"remark-toc": "^4.0.0",
"vfile": "^2.0.0",
"xo": "^0.17.1"
},

@@ -56,12 +57,49 @@ "files": [

"scripts": {
"build-md": "remark . --output --quiet",
"lint": "npm run lint-api && npm run lint-style",
"lint-api": "eslint .",
"lint-style": "jscs --reporter inline .",
"make": "npm run lint && npm run test-coverage",
"sub-install": "cd test/react/v0.14 && npm install && cd ../..",
"test": "npm run sub-install && npm run test-api",
"build": "remark *.md --output --quiet --frail",
"changelog": "standard-changelog -i history.md --overwrite",
"lint": "xo",
"test-api": "mocha --check-leaks test/index.js",
"test-coverage": "istanbul cover _mocha -- --check-leaks test/index.js"
"test-coverage": "nyc --reporter lcov mocha test/index.js",
"test": "npm run build && npm run lint && npm run sub-install && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"xo": {
"space": true,
"rules": {
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"import/no-dynamic-require": "off",
"max-nested-callbacks": "off",
"no-eq-null": "off",
"eqeqeq": [
"error",
"always",
{
"null": "ignore"
}
]
}
},
"remarkConfig": {
"plugins": [
"preset-lint-recommended",
"preset-lint-consistent",
"github",
"toc"
],
"settings": {
"bullet": "*"
}
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}

@@ -65,3 +65,3 @@ # remark-react

<div id='preview'>
{remark().use(reactRenderer).process(this.state.text).contents}
{remark().use(reactRenderer).processSync(this.state.text).contents}
</div>

@@ -104,2 +104,8 @@ </div>);

Note: as GFM uses `align` on `td` and `th`, and React doesn’t like that,
we [overwrite](https://github.com/mapbox/remark-react/blob/master/index.js#L94)
them through `remarkReactComponents` to use `style.textAlign` instead.
This means that if you set `td` or `td`, you’ll need to handle `align`
yourself.
* `toHast` (`object`, default: `{}`)

@@ -129,4 +135,7 @@ — Provides options for transforming MDAST document to HAST.

Additionally, syntax highlighting can be included (completely virtual) with
[`remark-react-lowlight`](https://github.com/bebraw/remark-react-lowlight).
## License
[MIT](LICENSE) © [Titus Wormer](http://wooorm.com), modified by [Tom MacWright](http://www.macwright.org/) and [Mapbox](https://www.mapbox.com/)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc