Socket
Socket
Sign inDemoInstall

react-highlight

Package Overview
Dependencies
22
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.0 to 0.8.0

.eslintrc

13

karma.conf.js

@@ -17,5 +17,5 @@ // Karma configuration

files: [
'node_modules/es5-shim/es5-shim.js',
'node_modules/react/dist/react-with-addons.js',
'test/**/*.jsx',
'node_modules/es5-shim/es5-shim.js',
'node_modules/react/dist/react-with-addons.js',
'test/**/*.js',
],

@@ -31,3 +31,3 @@

preprocessors: {
'test/**/*.jsx': ['webpack']
'test/**/*.js': ['webpack'],
},

@@ -38,3 +38,3 @@

loaders: [
{test: /\.(js|jsx)$/, loaders: ['babel']}
{test: /\.(js|jsx)$/, loaders: ['babel']},
]

@@ -44,2 +44,5 @@ },

react: 'React'
},
resolve: {
root: __dirname
}

@@ -46,0 +49,0 @@ },

@@ -13,3 +13,4 @@ 'use strict';

innerHTML: false,
className: null
className: null,
element: null
};

@@ -33,14 +34,28 @@ },

render: function render() {
var Element = this.props.element ? React.DOM[this.props.element] : null;
if (this.props.innerHTML) {
return React.createElement('div', { dangerouslySetInnerHTML: { __html: this.props.children }, className: this.props.className || null });
if (!Element) {
Element = React.DOM.div;
}
return Element({
dangerouslySetInnerHTML: { __html: this.props.children },
className: this.props.className || null
}, null);
} else {
return React.createElement(
'pre',
null,
React.createElement(
'code',
{ className: this.props.className },
this.props.children
)
);
if (Element) {
return Element({
className: this.props.className
}, this.props.children);
} else {
return React.createElement(
'pre',
null,
React.createElement(
'code',
{ className: this.props.className },
this.props.children
)
);
}
}

@@ -47,0 +62,0 @@ }

@@ -40,14 +40,28 @@ 'use strict';

render: function render() {
var Element = this.props.element ? React.DOM[this.props.element] : null;
if (this.props.innerHTML) {
return React.createElement('div', { dangerouslySetInnerHTML: { __html: this.props.children }, className: this.props.className || null });
if (!Element) {
Element = React.DOM.div;
}
return Element({
dangerouslySetInnerHTML: { __html: this.props.children },
className: this.props.className || null
}, null);
} else {
return React.createElement(
'pre',
null,
React.createElement(
'code',
{ className: this.props.className },
this.props.children
)
);
if (Element) {
return Element({
className: this.props.className
}, this.props.children);
} else {
return React.createElement(
'pre',
null,
React.createElement(
'code',
{ className: this.props.className },
this.props.children
)
);
}
}

@@ -54,0 +68,0 @@ }

{
"name": "react-highlight",
"version": "0.7.0",
"version": "0.8.0",
"description": "React component for syntax highlighting",

@@ -33,4 +33,7 @@ "main": "index.js",

"babel-core": "^5.6.18",
"babel-eslint": "^6.0.2",
"babel-loader": "^5.3.1",
"es5-shim": "^4.1.7",
"eslint": "^2.8.0",
"eslint-plugin-react": "^4.3.0",
"gulp": "^3.8.10",

@@ -43,2 +46,4 @@ "gulp-ruby-sass": "^0.7.1",

"karma": "^0.13.3",
"karma-jasmine": "^0.3.6",
"karma-phantomjs-launcher": "^0.2.1",
"karma-webpack": "^1.7.0",

@@ -51,13 +56,11 @@ "markdown-loader": "^0.1.2",

"react": "^0.14.0",
"react-addons-test-utils": "^0.14.3",
"webpack": "^1.12.2",
"webpack-dev-server": "^1.6.6",
"karma-jasmine": "^0.3.6",
"karma-phantomjs-launcher": "^0.2.1",
"react-addons-test-utils": "^0.14.3"
"webpack-dev-server": "^1.6.6"
},
"dependencies": {
"highlight.js": "^8.4.x",
"react": "^0.14.0",
"react-dom": "^0.14.0"
"react": "^0.14.0 || ^15.0.0",
"react-dom": "^0.14.0 || ^15.0.0"
}
}

@@ -9,3 +9,3 @@ # react-highlight

npm install react-highlight --save
```
```

@@ -26,2 +26,7 @@ ### Usage

Props:
* className: custom class name
* innerHTML: enable to render markup with dangerouslySetInnerHTML
* element: render code snippet inside specified element
#### Syntax highlighting of single code snippet

@@ -44,4 +49,4 @@ Code snippet that requires syntax highlighting should be passed as children to Highlight component in string format. Language name of code snippet should be specified as className.

<Highlight innerHTML={true}>
{"html with multiple code snippets"}
{"html with multiple code snippets"}
</Highlight>
```
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc