Home / Function/ markHTMLString() — astro Function Reference

markHTMLString() — astro Function Reference

Architecture documentation for the markHTMLString() function in escape.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  d09de695_fffc_1972_558d_93a415cbfd1b["markHTMLString()"]
  f9efe560_33a4_eae8_4bc6_06db77690a17["escape.ts"]
  d09de695_fffc_1972_558d_93a415cbfd1b -->|defined in| f9efe560_33a4_eae8_4bc6_06db77690a17
  a9777e18_d6c8_dd25_9401_be2009f3888d["unescapeHTML()"]
  a9777e18_d6c8_dd25_9401_be2009f3888d -->|calls| d09de695_fffc_1972_558d_93a415cbfd1b
  style d09de695_fffc_1972_558d_93a415cbfd1b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/runtime/server/escape.ts lines 34–48

export const markHTMLString = (value: any) => {
	// If value is already marked as an HTML string, there is nothing to do.
	if (value instanceof HTMLString) {
		return value;
	}
	// Cast to `HTMLString` to mark the string as valid HTML. Any HTML escaping
	// and sanitization should have already happened to the `value` argument.
	// NOTE: `unknown as string` is necessary for TypeScript to treat this as `string`
	if (typeof value === 'string') {
		return new HTMLString(value) as unknown as string;
	}
	// Return all other values (`number`, `null`, `undefined`) as-is.
	// The compiler will recursively stringify these correctly at a later stage.
	return value;
};

Domain

Subdomains

Called By

Frequently Asked Questions

What does markHTMLString() do?
markHTMLString() is a function in the astro codebase, defined in packages/astro/src/runtime/server/escape.ts.
Where is markHTMLString() defined?
markHTMLString() is defined in packages/astro/src/runtime/server/escape.ts at line 34.
What calls markHTMLString()?
markHTMLString() is called by 1 function(s): unescapeHTML.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free