Html 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.


constructors

a

Creates an a HTML annotation.

Signature

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

article

Creates an article HTML annotation.

Signature

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

aside

Creates an aside HTML annotation.

Signature

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

br

Creates a br HTML annotation.

Signature

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

code

Creates a code HTML annotation.

Signature

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

div

Creates a div HTML annotation.

Signature

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

em

Creates an em HTML annotation.

Signature

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

Creates a footer HTML annotation.

Signature

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

h1

Creates an h1 HTML annotation.

Signature

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

h2

Creates an h2 HTML annotation.

Signature

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

h3

Creates an h3 HTML annotation.

Signature

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

h4

Creates an h4 HTML annotation.

Signature

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

h5

Creates an h5 HTML annotation.

Signature

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

h6

Creates an h6 HTML annotation.

Signature

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

Creates a header HTML annotation.

Signature

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

hr

Creates an hr HTML annotation.

Signature

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

li

Creates an li HTML annotation.

Signature

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

main

Creates a main HTML annotation.

Signature

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

Creates a nav HTML annotation.

Signature

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

ol

Creates an ol HTML annotation.

Signature

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

p

Creates a p HTML annotation.

Signature

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

pre

Creates a pre HTML annotation.

Signature

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

section

Creates a section HTML annotation.

Signature

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

span

Creates a span HTML annotation.

Signature

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

strong

Creates a strong HTML annotation.

Signature

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

ul

Creates a ul HTML annotation.

Signature

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

guards

isHtml

Type guard that checks if a value is HTML annotation data.

Signature

export declare const isHtml: (data: unknown) => data is HtmlAnnotationData

Example

import * as Html from "effect-boxes/Html"
 
const value: unknown = { _tag: "Html", element: "div" }
console.log(Html.isHtml(value))
// true

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.

Signature

export declare const escapeHtml: (text: string) => string

Example

import * as Html from "effect-boxes/Html"
 
console.log(Html.escapeHtml("<hello & world>"))
// &lt;hello &amp; world&gt;