am_marks: Get all marks in a text object

View source: R/cursors.R

am_marksR Documentation

Get all marks in a text object

Description

Retrieves all marks (formatting/metadata annotations) present in a text object at a specific document state.

Usage

am_marks(obj)

Arguments

obj

An Automerge object ID (must be a text object)

Value

A list of marks, where each mark is a list with fields:

name

Character string identifying the mark

value

The mark's value (various types supported)

start

Integer start position (0-based inter-character position, inclusive)

end

Integer end position (0-based inter-character position, exclusive)

Returns an empty list if no marks are present. See am_mark() for indexing details.

Examples

doc <- am_create()
am_put(doc, AM_ROOT, "text", am_text("Hello World"))
text_obj <- am_get(doc, AM_ROOT, "text")

am_mark(text_obj, 0, 5, "bold", TRUE)
am_mark(text_obj, 6, 11, "italic", TRUE)

marks <- am_marks(text_obj)
marks
# List of 2 marks with name, value, start, end

am_close(doc)


automerge documentation built on Feb. 5, 2026, 5:08 p.m.