WordPress 的 HTML 实体工具函数。

安装

安装该模块

npm install @wordpress/html-entities --save

此包假设您的代码将在 ES2015+ 环境中运行。如果您使用的环境对这类语言特性和 API 的支持有限或完全不支持,您应在代码中包含@wordpress/babel-preset-default 随附的 polyfill。

API

decodeEntities

解码给定字符串中的 HTML 实体。

用法

import { decodeEntities } from '@wordpress/html-entities';

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

参数

  • html string: 包含 HTML 实体的字符串。

返回

  • string: 解码后的字符串。

为此包做出贡献

这是 Gutenberg 项目的一个独立包。该项目组织为 monorepo(单体仓库)。它由多个自包含的软件包组成,每个包都有特定的用途。此 monorepo 中的包发布到 npm,并被 WordPress 以及其他软件项目使用。

要了解有关为此包或整个 Gutenberg 做出贡献的更多信息,请阅读项目的主要 贡献者指南。