Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html-entities: set up auto-generated API docs #14267

Merged
merged 3 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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