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 element
  • span — annotate with a span element
  • escapeHtml — safely escape HTML entities

constructors

a

Creates an a HTML annotation.

Signature

declare const a: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

article

Creates an article HTML annotation.

Signature

declare const article: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

aside

Creates an aside HTML annotation.

Signature

declare const aside: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

br

Creates a br HTML annotation.

Signature

declare const br: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

code

Creates a code HTML annotation.

Signature

declare const code: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

div

Creates a div HTML annotation.

Signature

declare const div: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

em

Creates an em HTML annotation.

Signature

declare const em: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

Creates a footer HTML annotation.

Signature

declare const footer: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

h1

Creates an h1 HTML annotation.

Signature

declare const h1: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

h2

Creates an h2 HTML annotation.

Signature

declare const h2: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

h3

Creates an h3 HTML annotation.

Signature

declare const h3: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

h4

Creates an h4 HTML annotation.

Signature

declare const h4: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

h5

Creates an h5 HTML annotation.

Signature

declare const h5: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

h6

Creates an h6 HTML annotation.

Signature

declare const h6: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

Creates a header HTML annotation.

Signature

declare const header: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

hr

Creates an hr HTML annotation.

Signature

declare const hr: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

li

Creates an li HTML annotation.

Signature

declare const li: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

main

Creates a main HTML annotation.

Signature

declare const main: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

Creates a nav HTML annotation.

Signature

declare const nav: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

ol

Creates an ol HTML annotation.

Signature

declare const ol: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

p

Creates a p HTML annotation.

Signature

declare const p: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

pre

Creates a pre HTML annotation.

Signature

declare const pre: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

section

Creates a section HTML annotation.

Signature

declare const section: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

span

Creates a span HTML annotation.

Signature

declare const span: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

strong

Creates a strong HTML annotation.

Signature

declare const strong: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

ul

Creates a ul HTML annotation.

Signature

declare const ul: (
  attributes?: Record<string, string>
) => Annotation.Annotation<HtmlAnnotationData>;

Source

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

Source

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;
}

Source

HtmlRenderConfig (interface)

Configuration options for the HTML renderer.

Signature

export interface HtmlRenderConfig extends Renderer.RenderConfig {
  readonly indent?: boolean;
  readonly indentSize?: number;
}

Source

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>"))
// &lt;hello &amp; world&gt;

**Signature**

```ts
declare const escapeHtml: (text: string) => string

Source