Skip to content

Commit

Permalink
add initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathon Kelly committed Mar 14, 2016
1 parent 9214d27 commit bd1a095
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "react"]
}
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[{package,bower}.json]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
11 changes: 11 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "airbnb",

"rules": {
"indent": [2, 4, {"SwitchCase": 1}],
"max-len": [2, 140, 2],

"react/jsx-indent-props": [2, 4],
"react/prefer-stateless-function": 0
}
}
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# IntelliJ project files
.idea
*.iml
out
gen

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# lib
lib
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Jonathon Kelly

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# react-markdown-renderer
# react-markdown-renderer
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "react-markdown-renderer",
"version": "0.1.0",
"description": "Render markdown as a React component",
"main": "lib/index.js",
"scripts": {
"build": "babel $npm_package_config_entry --out-dir $npm_package_config_output",
"lint": "eslint --ignore-path .gitignore .",
"test": "npm run lint",
"prepublish": "npm run build && npm test"
},
"repository": {
"type": "git",
"url": "git+https://[email protected]/InsidersByte/react-markdown-renderer.git"
},
"config": {
"entry": "src",
"output": "lib",
"mainFile": "src/index.js"
},
"author": "Jonathon Kelly <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/InsidersByte/react-markdown-renderer/issues"
},
"homepage": "https://github.com/InsidersByte/react-markdown-renderer#readme",
"peerDependencies": {
"react": ">=0.14.7"
},
"dependencies": {
"marked": "^0.3.5"
},
"devDependencies": {
"babel-core": "^6.7.2",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"eslint": "^2.4.0",
"eslint-config-airbnb": "^6.1.0",
"eslint-plugin-react": "^4.2.1"
}
}
19 changes: 19 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import marked from 'marked';

class MarkdownRenderer extends React.Component {
render() {
const html = marked(this.props.markdown || '', { sanitize: true });

return (
<div className={this.props.className} dangerouslySetInnerHTML={{ __html: html }}></div>
);
}
}

MarkdownRenderer.propTypes = {
markdown: React.PropTypes.string.isRequired,
className: React.PropTypes.string,
};

export default MarkdownRenderer;

0 comments on commit bd1a095

Please sign in to comment.