From bd1a095005e34c63e3a9d84491e6da7a701df305 Mon Sep 17 00:00:00 2001 From: Jonathon Kelly Date: Mon, 14 Mar 2016 14:19:51 +0000 Subject: [PATCH] add initial files --- .babelrc | 3 +++ .editorconfig | 21 +++++++++++++++++++++ .eslintrc | 11 +++++++++++ .gitignore | 12 ++++++++++++ LICENSE | 21 +++++++++++++++++++++ README.md | 2 +- package.json | 41 +++++++++++++++++++++++++++++++++++++++++ src/index.js | 19 +++++++++++++++++++ 8 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 .babelrc create mode 100644 .editorconfig create mode 100644 .eslintrc create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 package.json create mode 100644 src/index.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..d4e5f8d --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015", "react"] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b57eb1d --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..8dec28a --- /dev/null +++ b/.eslintrc @@ -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 + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ef8ecd --- /dev/null +++ b/.gitignore @@ -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 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a998f94 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 83110f4..b8ab016 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# react-markdown-renderer \ No newline at end of file +# react-markdown-renderer diff --git a/package.json b/package.json new file mode 100644 index 0000000..2da98d9 --- /dev/null +++ b/package.json @@ -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://insidersbyte@github.com/InsidersByte/react-markdown-renderer.git" + }, + "config": { + "entry": "src", + "output": "lib", + "mainFile": "src/index.js" + }, + "author": "Jonathon Kelly ", + "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" + } +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..6adda0a --- /dev/null +++ b/src/index.js @@ -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 ( +
+ ); + } +} + +MarkdownRenderer.propTypes = { + markdown: React.PropTypes.string.isRequired, + className: React.PropTypes.string, +}; + +export default MarkdownRenderer;