├── .babelrc ├── .editorconfig ├── .gitignore ├── .travis.yml ├── LICENSE ├── PATENTS ├── README-htmltojsx.md ├── README.md ├── gulpfile.js ├── package.json ├── site ├── CNAME ├── htmltojsx.htm ├── index.htm ├── live_editor.js ├── magic-loader.js ├── react.css └── syntax.css ├── src ├── cli.js ├── htmltojsx-component.js ├── htmltojsx.js └── magic.js └── test ├── htmltojsx-test.js ├── test-helpers.js └── test.htm /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "react"] 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | temp 4 | .DS_Store 5 | *.sublime-project 6 | *.sublime-workspace 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 6 4 | script: gulp build 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD License for React-Magic 2 | 3 | Copyright (c) 2014, Facebook, Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | * Neither the name Facebook nor the names of its contributors may be used to 16 | endorse or promote products derived from this software without specific 17 | prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /PATENTS: -------------------------------------------------------------------------------- 1 | Additional Grant of Patent Rights Version 2 2 | 3 | "Software" means the React-Magic software distributed by Facebook, Inc. 4 | 5 | Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software 6 | ("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable 7 | (subject to the termination provision below) license under any Necessary 8 | Claims, to make, have made, use, sell, offer to sell, import, and otherwise 9 | transfer the Software. For avoidance of doubt, no license is granted under 10 | Facebook's rights in any patent claims that are infringed by (i) modifications 11 | to the Software made by you or any third party or (ii) the Software in 12 | combination with any software or other technology. 13 | 14 | The license granted hereunder will terminate, automatically and without notice, 15 | if you (or any of your subsidiaries, corporate affiliates or agents) initiate 16 | directly or indirectly, or take a direct financial interest in, any Patent 17 | Assertion: (i) against Facebook or any of its subsidiaries or corporate 18 | affiliates, (ii) against any party if such Patent Assertion arises in whole or 19 | in part from any software, technology, product or service of Facebook or any of 20 | its subsidiaries or corporate affiliates, or (iii) against any party relating 21 | to the Software. Notwithstanding the foregoing, if Facebook or any of its 22 | subsidiaries or corporate affiliates files a lawsuit alleging patent 23 | infringement against you in the first instance, and you respond by filing a 24 | patent infringement counterclaim in that lawsuit against that party that is 25 | unrelated to the Software, the license granted hereunder will not terminate 26 | under section (i) of this paragraph due to such counterclaim. 27 | 28 | A "Necessary Claim" is a claim of a patent owned by Facebook that is 29 | necessarily infringed by the Software standing alone. 30 | 31 | A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, 32 | or contributory infringement or inducement to infringe any patent, including a 33 | cross-claim or counterclaim. 34 | -------------------------------------------------------------------------------- /README-htmltojsx.md: -------------------------------------------------------------------------------- 1 | HTMLtoJSX 2 | ========= 3 | 4 | HTMLtoJSX converts HTML to JSX for use with [React](facebook.github.io/react/). 5 | 6 | Installation 7 | ============ 8 | 9 | ``` 10 | npm install htmltojsx 11 | ``` 12 | 13 | Alternatively, a web-based version is available at http://magic.reactjs.net/htmltojsx.htm 14 | 15 | Usage 16 | ===== 17 | HTMLtoJSX can be used either as a command-line application or as a Node.js module. To use the command-line version, invoke the `htmltojsx` command: 18 | 19 | ``` 20 | $ htmltojsx --help 21 | Converts HTML to JSX for use with React. 22 | Usage: htmltojsx [-c ComponentName] file.htm 23 | 24 | Examples: 25 | htmltojsx -c AwesomeComponent awesome.htm Creates React component "AwesomeComponent" based on awesome.htm 26 | 27 | 28 | Options: 29 | --className, -c Create a React component (wraps JSX in React.createClass call) 30 | --help Show help 31 | ``` 32 | 33 | To use the Node.js module, `require('htmltojsx')` and create a new instance. This is the same interface as the web-based version: 34 | 35 | ```js 36 | var HTMLtoJSX = require('htmltojsx'); 37 | var converter = new HTMLtoJSX({ 38 | createClass: true, 39 | outputClassName: 'AwesomeComponent' 40 | }); 41 | var output = converter.convert('
Hello world!
'); 42 | ``` 43 | 44 | Changelog 45 | ========= 46 | 0.3.0 - 4th September 2017 47 | -------------------------- 48 | - [#97](https://github.com/reactjs/react-magic/pull/97) - Update to React 15 49 | - [#100](https://github.com/reactjs/react-magic/pull/100) - Remove JSX class-level indention when transforming HTML into JSX 50 | - [#136](https://github.com/reactjs/react-magic/pull/136) and [#138](https://github.com/reactjs/react-magic/pull/138) - Handle SVG attributes 51 | 0.2.6 - 28th November 2016 52 | -------------------------- 53 | - [#55](https://github.com/reactjs/react-magic/pull/55) - Handle braces in text. *Thanks to [Solar Olugebefola](https://github.com/solugebefola)* 54 | - [#49](https://github.com/reactjs/react-magic/pull/49) - Fix quotation mark replacement. *Thanks to [Geoffrey Challen](https://github.com/gchallen)* 55 | 56 | 0.2.5 - 26th October 2015 57 | ------------------------- 58 | - [#33](https://github.com/reactjs/react-magic/issues/33) - Correctly handle `').trim()) 247 | .toBe('