Skip to content

Commit

Permalink
html-entities: set up auto-generated API docs (#14267)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolosw authored Mar 6, 2019
1 parent 52355c4 commit 7d98658
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/update-readmes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const packages = [
//'edit-post',
'element',
'escape-html',
//'html-entities',
'html-entities',
//'i18n',
//'keycodes',
//'plugins',
Expand Down
28 changes: 28 additions & 0 deletions packages/html-entities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,32 @@ npm install @wordpress/html-entities --save

_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) will add support for these methods. Learn more about it in [Babel docs](https://babeljs.io/docs/en/next/caveats)._

## API

<!-- START TOKEN(Autogenerated API docs) -->

### decodeEntities

[src/index.js#L16-L35](src/index.js#L16-L35)

Decodes the HTML entities from a given string.

**Usage**

```js
const result = decodeEntities( '&aacute;' );
console.log( result ); // result will be "á"
```

**Parameters**

- **html** `string`: String that contain HTML entities.

**Returns**

`string`: The decoded string.


<!-- END TOKEN(Autogenerated API docs) -->

<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
13 changes: 13 additions & 0 deletions packages/html-entities/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
let _decodeTextArea;

/**
* Decodes the HTML entities from a given string.
*
* @param {string} html String that contain HTML entities.
*
* @example
* ```js
* const result = decodeEntities( '&aacute;' );
* console.log( result ); // result will be "á"
* ```
*
* @return {string} The decoded string.
*/
export function decodeEntities( html ) {
// not a string, or no entities to decode
if ( 'string' !== typeof html || -1 === html.indexOf( '&' ) ) {
Expand Down

0 comments on commit 7d98658

Please sign in to comment.