mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-24 11:45:26 +03:00
docs(escape, unescape): Add docs for escape & unescape
This commit is contained in:
parent
2dab51b468
commit
4fea8d2a00
@ -222,6 +222,8 @@ function sidebar(): DefaultTheme.Sidebar {
|
||||
{ text: 'padStart (compat)', link: '/ja/reference/compat/string/padStart' },
|
||||
{ text: 'padEnd (compat)', link: '/ja/reference/compat/string/padEnd' },
|
||||
{ text: 'deburr', link: '/ja/reference/string/deburr' },
|
||||
{ text: 'escape', link: '/ja/reference/string/escape' },
|
||||
{ text: 'unescape', link: '/ja/reference/string/unescape' },
|
||||
{ text: 'pad', link: '/ja/reference/string/pad' },
|
||||
{ text: 'repeat (compat)', link: '/ja/reference/compat/string/pad' },
|
||||
],
|
||||
|
@ -239,6 +239,8 @@ function sidebar(): DefaultTheme.Sidebar {
|
||||
{ text: 'padStart (호환성)', link: '/ko/reference/compat/string/padStart' },
|
||||
{ text: 'padEnd (호환성)', link: '/ko/reference/compat/string/padEnd' },
|
||||
{ text: 'deburr', link: '/ko/reference/string/deburr' },
|
||||
{ text: 'escape', link: '/ko/reference/string/escape' },
|
||||
{ text: 'unescape', link: '/ko/reference/string/unescape' },
|
||||
{ text: 'pad', link: '/ko/reference/string/pad' },
|
||||
{ text: 'repeat (호환성)', link: '/ko/reference/compat/string/pad' },
|
||||
],
|
||||
|
28
docs/ja/reference/string/escape.md
Normal file
28
docs/ja/reference/string/escape.md
Normal file
@ -0,0 +1,28 @@
|
||||
# escape
|
||||
|
||||
`"&"`、`"<"`、`">"`、`'"'`、および "\`" のような文字列を、HTMLで安全に使用できるエンティティ文字列に変換します。例えば、`"<"` は `"<"` に変換されます。
|
||||
|
||||
## インターフェース
|
||||
|
||||
```typescript
|
||||
function escape(str: string): string;
|
||||
```
|
||||
|
||||
### パラメータ
|
||||
|
||||
- `str` (`string`): HTMLで安全に使用するために変換する文字列。
|
||||
|
||||
### 戻り値
|
||||
|
||||
(`string`): 変換された文字列。
|
||||
|
||||
## 例
|
||||
|
||||
```typescript
|
||||
import { escape } from 'es-toolkit/string';
|
||||
|
||||
escape('This is a <div> element.'); // returns 'This is a <div> element.'
|
||||
escape('This is a "quote"'); // returns 'This is a "quote"'
|
||||
escape("This is a 'quote'"); // returns 'This is a 'quote''
|
||||
escape('This is a & symbol'); // returns 'This is a & symbol'
|
||||
```
|
28
docs/ja/reference/string/unescape.md
Normal file
28
docs/ja/reference/string/unescape.md
Normal file
@ -0,0 +1,28 @@
|
||||
# unescape
|
||||
|
||||
`"&"`、`"<"`、`">"`、`"""`、および `"'"` のようなHTMLエンティティ文字列を元の文字列に戻します。これは[escape](./escape.md)の逆の操作です。
|
||||
|
||||
## インターフェース
|
||||
|
||||
```typescript
|
||||
function unescape(str: string): string;
|
||||
```
|
||||
|
||||
### パラメータ
|
||||
|
||||
- `str` (`string`): 変換する文字列。
|
||||
|
||||
### 戻り値
|
||||
|
||||
(`string`): 変換された文字列。
|
||||
|
||||
## 例
|
||||
|
||||
```typescript
|
||||
import { unescape } from 'es-toolkit/string';
|
||||
|
||||
unescape('This is a <div> element.'); // returns 'This is a <div> element.'
|
||||
unescape('This is a "quote"'); // returns 'This is a "quote"'
|
||||
unescape('This is a 'quote''); // returns 'This is a 'quote''
|
||||
unescape('This is a & symbol'); // returns 'This is a & symbol'
|
||||
```
|
28
docs/ko/reference/string/escape.md
Normal file
28
docs/ko/reference/string/escape.md
Normal file
@ -0,0 +1,28 @@
|
||||
# escape
|
||||
|
||||
`"&"`, `"<"`, `">"`, `'"'`, and `"'"` 같은 문자열을 HTML에 쓰기 안전한 엔티티 문자열로 바꿔요. 예를 들어서, `"<"`은 `"<"`가 돼요.
|
||||
|
||||
## 인터페이스
|
||||
|
||||
```typescript
|
||||
function escape(str: string): string;
|
||||
```
|
||||
|
||||
### 파라미터
|
||||
|
||||
- `str` (`string`): HTML에서 쓰기 안전하게 바꿀 문자열.
|
||||
|
||||
### 반환 값
|
||||
|
||||
(`string`): 변환된 문자열.
|
||||
|
||||
## 예시
|
||||
|
||||
```typescript
|
||||
import { escape } from 'es-toolkit/string';
|
||||
|
||||
escape('This is a <div> element.'); // returns 'This is a <div> element.'
|
||||
escape('This is a "quote"'); // returns 'This is a "quote"'
|
||||
escape("This is a 'quote'"); // returns 'This is a 'quote''
|
||||
escape('This is a & symbol'); // returns 'This is a & symbol'
|
||||
```
|
28
docs/ko/reference/string/unescape.md
Normal file
28
docs/ko/reference/string/unescape.md
Normal file
@ -0,0 +1,28 @@
|
||||
# unescape
|
||||
|
||||
`&`, `<`, `>`, `"`, `'` 같은 HTML 엔티티 문자열을 원래 문자열로 바꿔요. [`escape`](./escape.md)의 반대 연산이에요.
|
||||
|
||||
## 인터페이스
|
||||
|
||||
```typescript
|
||||
function unescape(str: string): string;
|
||||
```
|
||||
|
||||
### 파라미터
|
||||
|
||||
- `str` (`string`): 변환할 문자열.
|
||||
|
||||
### 반환 값
|
||||
|
||||
(`string`): 변환된 문자열.
|
||||
|
||||
## 예시
|
||||
|
||||
```typescript
|
||||
import { unescape } from 'es-toolkit/string';
|
||||
|
||||
unescape('This is a <div> element.'); // returns 'This is a <div> element.'
|
||||
unescape('This is a "quote"'); // returns 'This is a "quote"'
|
||||
unescape('This is a 'quote''); // returns 'This is a 'quote''
|
||||
unescape('This is a & symbol'); // returns 'This is a & symbol'
|
||||
```
|
@ -1,6 +1,6 @@
|
||||
# escape
|
||||
|
||||
Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities.
|
||||
Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities. For example, `"<"` becomes `"<"`.
|
||||
|
||||
## Signature
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# unescape
|
||||
|
||||
The inverse of [`escape`](./escape.md); this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `str` to their corresponding characters.
|
||||
Converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `str` to their corresponding characters. It is the inverse of [`escape`](./escape.md).
|
||||
|
||||
## Signature
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
# escape
|
||||
|
||||
将 `str` 中的 "&", "<", ">", '"', "'", 和 "`" 字符转换为 HTML 实体字符。
|
||||
将 `str` 中的 "&", "<", ">", '"', "'", 和 "\`" 字符转换为 HTML 实体字符。例如,`"<"` 会被转换为 `"<"`。
|
||||
|
||||
|
||||
## 签名
|
||||
|
||||
|
@ -8,6 +8,7 @@ const htmlEscapes: Record<string, string> = {
|
||||
|
||||
/**
|
||||
* Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities.
|
||||
* For example, "<" becomes "<".
|
||||
*
|
||||
* @param {string} str The string to escape.
|
||||
* @returns {string} Returns the escaped string.
|
||||
|
@ -7,7 +7,8 @@ const htmlUnescapes: Record<string, string> = {
|
||||
};
|
||||
|
||||
/**
|
||||
* The inverse of `escape`. This method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `str` to their corresponding characters.
|
||||
* Converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `str` to their corresponding characters.
|
||||
* It is the inverse of `escape`.
|
||||
*
|
||||
* @param {string} str The string to unescape.
|
||||
* @returns {string} Returns the unescaped string.
|
||||
|
Loading…
Reference in New Issue
Block a user