Skip to main content

spec.skip_string

spec.skip_string(text, i)

The end of the TOML string that opens at text[i], and its line-end backslashes.

A basic string (") honours escapes; a literal string (') does not. Either is multi-line when it opens with three quotes, and then up to two more quotes before the closing three belong to the value. A single-line string ends at its closing quote or before the line break.

Parameters

Name Type Description Default
text str The TOML text. required
i int The offset of the opening quote. required

Returns

Name Type Description
tuple[int, list[int]] tuple[int, list[int]]: The offset after the string, and the offsets of the backslashes that end a line inside a multi-line basic string.

Examples

from babregen.spec import skip_string

text = "a = ['x]', 1]  # [b]"
end, backslashes = skip_string(text, 5)
print(repr(text[5:end]), backslashes)
"'x]'" []