The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Title: 'HTML' Element Construction
Version: 1.0.0
Description: Provides a deterministic, framework-agnostic Domain-Specific Language for building 'HTML' nodes and rendering them to a string.
License: MIT + file LICENSE
URL: https://github.com/sigflux/hypertext
BugReports: https://github.com/sigflux/hypertext/issues
Encoding: UTF-8
RoxygenNote: 7.3.3
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-02-23 02:52:02 UTC; mwavu
Author: Kennedy Mwavu ORCID iD [aut, cre], Sigflux [cph, fnd]
Maintainer: Kennedy Mwavu <mwavukennedy@gmail.com>
Repository: CRAN
Date/Publication: 2026-02-27 20:00:02 UTC

Escape special HTML characters

Description

Replaces &, <, >, ⁠"⁠, and ⁠'⁠ with their HTML entity equivalents.

Usage

.escape_html(x)

Arguments

x

A character string.

Value

A character string with HTML special characters escaped.


Flatten children

Description

Recursively unpack plain lists (but not hypertext.tag nodes) so users can pass list(tags$li("a"), tags$li("b")) as a single child argument.

Usage

.flatten_children(x)

Arguments

x

A list of children.

Value

A flat list of children.


Create a tag function for a normal (non-void) element

Description

Create a tag function for a normal (non-void) element

Usage

.make_tag(tag_name)

Create a tag function for a void (self-closing) element

Description

Create a tag function for a void (self-closing) element

Usage

.make_void_tag(tag_name)

Render a named list of attributes to a single HTML attribute string

Description

Usage

.render_attrs(attrs)

Arguments

attrs

A named list of attribute values.

Value

A single character string (leading space included when non-empty).


Create an HTML element node

Description

Low-level constructor. Named arguments become attributes; unnamed arguments become children (text or nested nodes). This function is used internally by every entry in the tags list.

Usage

.tag(tag_name, ..., .void = FALSE)

Arguments

tag_name

Character scalar – the HTML element name.

...

Attributes (named) and children (unnamed).

.void

Logical; if TRUE the element is self-closing and children are ignored.

Value

A list of class "hypertext.tag" with components tag, attrs, and children.


Render an HTML node tree to a character string

Description

Converts an hypertext.tag object (and all its descendants) into an HTML string. Text children are escaped; nested hypertext.tag children are rendered recursively.

Usage

render(x)

## S3 method for class 'hypertext.tag'
render(x)

## Default S3 method:
render(x)

## S3 method for class 'list'
render(x)

Arguments

x

An hypertext.tag object, a character string, or a list of these.

Value

A single character string of HTML.


HTML tag functions

Description

A named list of functions, one per HTML5 element. Access individual tags with tags$div(...), tags$p(...), etc.

Usage

tags

Format

An object of class list of length 115.

Details

Named arguments become HTML attributes; unnamed arguments become child nodes or text content.

Boolean / valueless attributes

Pass NA or TRUE as the attribute value to produce a valueless attribute (e.g. disabled). FALSE or NULL suppresses the attribute entirely.

Multi-value attributes

Character vectors of length > 1 are collapsed with a space, so class = c("a", "b") renders as class="a b".

Examples

tags$p(class = "lead", "Hello, world!")
render(tags$div(id = "app", tags$h1("Title")))

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.