namespace AIStudio.Tools.DocumentSegments;
///
/// A segment of a document which is text itself: where its words lie in the source, and which markup each of
/// its tags stands for.
///
/// Where the segment starts in the source.
/// Where the segment ends in the source, exclusive.
/// The segment, as a model gets it.
/// The markup which the opening tag of each pair stands for, e.g., "[" of a Markdown link.
/// The markup which the closing tag of each pair stands for, e.g., "](https://example.org)".
/// The markup which each tag of its own stands for, e.g., a code span.
/// Makes the words of this segment fit the format in place of what the writer gets, e.g., within an optional argument of LaTeX, which a closing bracket would end; null for the writer's. Like the writer's, it gets one run of words between two tags at a time, so its start may be the start of a line.
/// The tags of their own which the writer leaves out when the model dropped them, e.g., a line break of Markdown, which would show as a backslash after the words; null for none.
/// Makes the whole new text of this segment fit the format, once its words and the markup of its tags are written, e.g., quotes around the new value of an attribute of a web page which had none; null to leave it as it is.
public sealed record TextSegment(
int Start,
int End,
DocumentSegment Segment,
IReadOnlyDictionary Openings,
IReadOnlyDictionary Closings,
IReadOnlyDictionary Placeholders,
Func? FormatWords = null,
IReadOnlySet? OptionalPlaceholders = null,
Func? FormatNewText = null);