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

docs(html): improve API docs #4878

Merged
merged 1 commit into from
May 29, 2024
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
1 change: 1 addition & 0 deletions _tools/check_docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const ENTRY_POINTS = [
"../fmt/duration.ts",
"../fmt/printf.ts",
"../front_matter/mod.ts",
"../html/mod.ts",
"../http/mod.ts",
"../internal/mod.ts",
"../jsonc/mod.ts",
Expand Down
11 changes: 9 additions & 2 deletions html/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const rawRe = new RegExp(`[${[...rawToEntity.keys()].join("")}]`, "g");
/**
* Escapes text for safe interpolation into HTML text content and quoted attributes.
*
* @example
* @example Usage
* ```ts
* import { escape } from "@std/html/entities";
*
Expand All @@ -35,6 +35,9 @@ const rawRe = new RegExp(`[${[...rawToEntity.keys()].join("")}]`, "g");
* // even if named HTML entities exist for them.
* escape("þð"); // "þð"
* ```
*
* @param str The string to escape.
* @returns The escaped string.
*/
export function escape(str: string): string {
return str.replaceAll(rawRe, (m) => rawToEntity.get(m)!);
Expand All @@ -57,7 +60,7 @@ const entityListRegexCache = new WeakMap<EntityList, RegExp>();
/**
* Unescapes HTML entities in text.
*
* @example
* @example Usage
* ```ts
* import { unescape } from "@std/html/entities";
*
Expand All @@ -70,6 +73,10 @@ const entityListRegexCache = new WeakMap<EntityList, RegExp>();
*
* unescape("&thorn;&eth;", { entityList }); // "þð"
* ```
*
* @param str The string to unescape.
* @param options Options for unescaping.
* @returns The unescaped string.
*/
export function unescape(
str: string,
Expand Down