Html.ts overview
HTML element annotations for web-based box rendering.
Provides annotation constructors for common HTML elements (div, span, p, headings, etc.) that the HTML renderer interprets as markup. Use these to produce styled HTML output from annotated boxes.
See
div— annotate with a div elementspan— annotate with a span elementescapeHtml— safely escape HTML entities
constructors
a
Creates an a HTML annotation.
Signature
declare const a: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;article
Creates an article HTML annotation.
Signature
declare const article: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;aside
Creates an aside HTML annotation.
Signature
declare const aside: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;br
Creates a br HTML annotation.
Signature
declare const br: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;code
Creates a code HTML annotation.
Signature
declare const code: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;div
Creates a div HTML annotation.
Signature
declare const div: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;em
Creates an em HTML annotation.
Signature
declare const em: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;footer
Creates a footer HTML annotation.
Signature
declare const footer: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;h1
Creates an h1 HTML annotation.
Signature
declare const h1: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;h2
Creates an h2 HTML annotation.
Signature
declare const h2: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;h3
Creates an h3 HTML annotation.
Signature
declare const h3: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;h4
Creates an h4 HTML annotation.
Signature
declare const h4: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;h5
Creates an h5 HTML annotation.
Signature
declare const h5: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;h6
Creates an h6 HTML annotation.
Signature
declare const h6: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;header
Creates a header HTML annotation.
Signature
declare const header: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;hr
Creates an hr HTML annotation.
Signature
declare const hr: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;li
Creates an li HTML annotation.
Signature
declare const li: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;main
Creates a main HTML annotation.
Signature
declare const main: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;nav
Creates a nav HTML annotation.
Signature
declare const nav: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;ol
Creates an ol HTML annotation.
Signature
declare const ol: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;p
Creates a p HTML annotation.
Signature
declare const p: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;pre
Creates a pre HTML annotation.
Signature
declare const pre: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;section
Creates a section HTML annotation.
Signature
declare const section: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;span
Creates a span HTML annotation.
Signature
declare const span: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;strong
Creates a strong HTML annotation.
Signature
declare const strong: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;ul
Creates a ul HTML annotation.
Signature
declare const ul: (
attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;guards
isHtml
Type guard that checks if a value is HTML annotation data.
Example
```typescript
import * as Html from "effect-boxes/Html"
const value: unknown = { _tag: "Html", element: "div" }
console.log(Html.isHtml(value))
// true
**Signature**
```ts
declare const isHtml: (data: unknown) => data is HtmlAnnotationData
models
HtmlAnnotationData (interface)
Data payload stored in HTML annotations.
Signature
export interface HtmlAnnotationData {
readonly _tag: "Html";
readonly element: string;
readonly attributes?: Record<string, string> | undefined;
}HtmlRenderConfig (interface)
Configuration options for the HTML renderer.
Signature
export interface HtmlRenderConfig extends Renderer.RenderConfig {
readonly indent?: boolean;
readonly indentSize?: number;
}utilities
escapeHtml
Escapes special characters for safe HTML text output.
Example
```typescript
import * as Html from "effect-boxes/Html"
console.log(Html.escapeHtml("<hello & world>"))
// <hello & world>
**Signature**
```ts
declare const escapeHtml: (text: string) => string