diff --git a/.github/workflows/size-limit.yml b/.github/workflows/size-limit.yml new file mode 100644 index 00000000..366cb99b --- /dev/null +++ b/.github/workflows/size-limit.yml @@ -0,0 +1,15 @@ +name: size +on: + pull_request: + branches: + - master +jobs: + size: + runs-on: ubuntu-latest + env: + CI_JOB_NUMBER: 1 + steps: + - uses: actions/checkout@v2 + - uses: andresz1/size-limit-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.size-limit.json b/.size-limit.json new file mode 100644 index 00000000..e56016a1 --- /dev/null +++ b/.size-limit.json @@ -0,0 +1,6 @@ +[ + { + "path": "dist/html-react-parser.min.js", + "limit": "8 KB" + } +] diff --git a/CHANGELOG.md b/CHANGELOG.md index 39b2469e..32bbf214 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,14 @@ -# Change Log +# Changelog All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.1.0](https://github.com/remarkablemark/html-react-parser/compare/v1.0.0...v1.1.0) (2020-12-26) + + +### Features + +* **index:** export `domhandler` node types ([dfa0c19](https://github.com/remarkablemark/html-react-parser/commit/dfa0c1978684f42cdcabd32e95379dfb52ef1d0c)) + # [1.0.0](https://github.com/remarkablemark/html-react-parser/compare/v0.14.3...v1.0.0) (2020-12-14) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 395dc477..c99cec22 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,16 @@ Make your change. Add tests and/or documentation. Ensure all tests and lint pass ```sh $ npm test $ npm run lint +$ npm run lint:dts +``` + +Write a commit message that follows the [Conventional Commits][commit] specification. + +The commit message will be linted during the pre-commit Git hook. +To manually lint the most recent commit message: + +```sh +$ git log -1 --pretty=format:"%s" | npx commitlint ``` Push to your fork and [submit a pull request][pr]. @@ -42,27 +52,20 @@ Things that will improve the chance that your pull request will be accepted: - [ ] Write good documentation. - [ ] Write a [good commit message][commit]. -[ci]: https://travis-ci.org/remarkablemark/html-react-parser +[ci]: https://github.com/remarkablemark/html-react-parser/actions?query=workflow%3Abuild [commit]: https://www.conventionalcommits.org/ ## Test -Run tests: - -```sh -$ npm test -``` - Run tests with coverage: ```sh -$ npm run test:coverage +$ npm test ``` View coverage report in your browser: ```sh -$ npm run test:coverage:report $ open coverage/index.html ``` @@ -80,7 +83,7 @@ Fix lint errors: $ npm run lint:fix ``` -Test TypeScript declaration file for style and correctness: +Test TypeScript declaration files for style and correctness: ```sh $ npm run lint:dts @@ -92,5 +95,5 @@ Only collaborators with credentials can release and publish: ```sh $ npm run release -$ npm publish && git push --follow-tags +$ git push --follow-tags && npm publish ``` diff --git a/README.md b/README.md index 1253e099..d55ea4e6 100644 --- a/README.md +++ b/README.md @@ -15,27 +15,30 @@ HTML to React parser that works on both the server (Node.js) and the client (bro HTMLReactParser(string[, options]) ``` -It converts an HTML string to one or more [React elements](https://reactjs.org/docs/react-api.html#creating-react-elements). There's also an option to [replace an element](#replacedomnode) with your own. +The parser converts an HTML string to one or more [React elements](https://reactjs.org/docs/react-api.html#creating-react-elements). -Example: +To replace an element with a custom element, check out the [replace option](#replacedomnode). + +#### Example ```js const parse = require('html-react-parser'); -parse('
text
'); // equivalent to `React.createElement('div', {}, 'text')` +parse('

Hello, World!

'); // React.createElement('p', {}, 'Hello, World!') ``` -[CodeSandbox](https://codesandbox.io/s/940pov1l4w) | [Repl.it](https://repl.it/@remarkablemark/html-react-parser) | [JSFiddle](https://jsfiddle.net/remarkablemark/7v86d800/) | [Examples](https://github.com/remarkablemark/html-react-parser/tree/master/examples) +[CodeSandbox](https://codesandbox.io/s/940pov1l4w) | [CodeSandbox (TypeScript)](https://codesandbox.io/s/html-react-parser-z0kp6) | [Repl.it](https://repl.it/@remarkablemark/html-react-parser) | [JSFiddle](https://jsfiddle.net/remarkablemark/7v86d800/) | [Examples](https://github.com/remarkablemark/html-react-parser/tree/master/examples)
Table of Contents - [Install](#install) - [Usage](#usage) - - [Options](#options) - - [replace(domNode)](#replacedomnode) + - [replace(domNode)](#replacedomnode) - [library](#library) - [htmlparser2](#htmlparser2) - [trim](#trim) +- [Migration](#migration) + - [v1.0.0](#v100) - [FAQ](#faq) - [Is this XSS safe?](#is-this-xss-safe) - [Does invalid HTML get sanitized?](#does-invalid-html-get-sanitized) @@ -46,7 +49,8 @@ parse('
text
'); // equivalent to `React.createElement('div', {}, 'text - [Elements aren't nested correctly](#elements-arent-nested-correctly) - [Warning: validateDOMNesting(...): Whitespace text nodes cannot appear as a child of table](#warning-validatedomnesting-whitespace-text-nodes-cannot-appear-as-a-child-of-table) - [Don't change case of tags](#dont-change-case-of-tags) -- [Benchmarks](#benchmarks) + - [TS Error: Property 'attribs' does not exist on type 'DOMNode'](#ts-error-property-attribs-does-not-exist-on-type-domnode) +- [Performance](#performance) - [Contributors](#contributors) - [Code Contributors](#code-contributors) - [Financial Contributors](#financial-contributors) @@ -75,7 +79,7 @@ $ yarn add html-react-parser ```html - +