ass_wrap_range
Wrap a character range in an ASS override block and restore the outer styling after it. Supports visible or raw index scopes for precise subtitle edits.
Instructions
Wrap a character range in an override block, restoring the outer state.
Args:
index / text / doc_id: the line to edit (0-based index of doc_id or a
raw string).
start: range start. A plain index when scope="plain" (the
default), a raw index when scope="raw".
end: range end, exclusive. Same index system as start; None
means "to the end of the line" (the visible end / the raw end).
override: the tags to apply, with or without the surrounding braces and
with or without the leading backslash (r"\fscx200",
"fscx200" and r"{\fscx200}" are all accepted). Braces and
line breaks inside the payload are rejected.
doc_id: document holding index.
scope: "plain" (default) counts only visible characters — override
blocks and the \N/\n line-break escapes are not counted, so
the same start/end cover the same glyphs no matter how many
tags precede them. "raw" counts every stored code point
including braces, which is what you want when you already have
offsets into the stored Text field. A raw boundary that would
land inside an override block is refused with a ToolError
instead of silently splitting the block.
in_place: write back to the document (snapshot-backed). The raw-string
mode never writes.
The tags that were in effect before start are re-emitted after end
when they changed inside the range, so the override applies to exactly the
requested characters. warnings reports tags that had no previous value
to restore (there is nothing to restore for e.g. \an).
Returns {"source", "index", "doc_id", "scope", "start", "end", "raw_start", "raw_end", "plain_start", "plain_end", "override", "text", "plain_text", "changed", "written", "warnings"}. start/end are
echoed in the requested index system; plain_start/plain_end are always
plain (visible character) indices and raw_start/raw_end are always
raw offsets into the stored line, so the two systems stay comparable no
matter which one was passed in.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | No | ||
| text | No | ||
| index | No | ||
| scope | No | plain | |
| start | No | ||
| doc_id | No | ||
| in_place | No | ||
| override | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||