doc <- am_create()
am_put(doc, AM_ROOT, "text", am_text("Hello World"))
text_obj <- am_get(doc, AM_ROOT, "text")
# Mark "Hello" as bold (positions 0-4, characters 0-4)
am_mark(text_obj, 0, 5, "bold", TRUE)
# Mark "World" as italic with expansion
am_mark(text_obj, 6, 11, "italic", TRUE,
expand = AM_MARK_EXPAND_BOTH)
# Get all marks
marks <- am_marks(text_obj)
marks
am_close(doc)
Run the code above in your browser using DataLab