Subtitles module

load_subtitles_from_memory

procedureSource

Parses subtitle text, which opens with a [1] version line. :name starts a section (::name marks it finalized), =speaker 1.5 starts a timed instant, the lines after it are speech, ++ text is a stage direction, and +name parameter begin end adds an event. The sections point into data, which must outlive them. short_name names the source in error messages.

load_subtitles_from_memory :: (
    data: string,
    short_name: string
) -> (bool, Subtitles)

Parameters

data: string
short_name: string

Returns

bool
Example↗
text := "[1]\n:intro\n=guard 1.5\nHalt!\n++ raises a hand\n";
ok, subtitles := load_subtitles_from_memory(text, "intro");
assert(ok);
section := subtitles.all_sections[0];
assert(section.name == "intro" && section.instants[0].speaker == "guard");
assert(section.instants[0].lines.count == 2);
free(*subtitles);

See also