namespace AIStudio.Tools.DocumentSegments.Latex; /// /// What the parser and the reader know about a command. /// /// What the command means for the segments. /// How many arguments in braces the command takes. /// Whether the command takes arguments in brackets before its last argument in braces, or anywhere when it takes none in braces. /// Which of the arguments in braces holds the words of a WORDS or HEADING command, counted from 0. internal sealed record LatexCommand(LatexCommandRole Role, int MandatoryArguments, bool TakesOptionalArguments, int TextArgument = 0) { /// /// A command the reader does not know, e.g., a macro of the document: a tag of its own with every argument /// which follows right after it, since such a macro may hold anything. /// public static readonly LatexCommand UNKNOWN = new(LatexCommandRole.INLINE, int.MaxValue, true) { IsKnown = false }; /// /// Whether the reader knows the command. Only the arguments of a known command may follow after white space; /// for any other, a group after a space is words of its own. /// public bool IsKnown { get; init; } = true; /// /// Whether LaTeX reads the first argument in braces as it stands, e.g., the address of \url, in which a percent sign is no comment. /// public bool HasRawFirstArgument { get; init; } /// /// Whether the command takes an argument in parentheses, e.g., the trimming of \cmidrule(lr). /// public bool TakesParenthesizedArgument { get; init; } }