parseChemicalArgument method
Implementation
LatexNode parseChemicalArgument() {
// The arguments for the \ce command are typically enclosed in {}
if (tokenStream.peek() is LeftBraceToken) {
tokenStream.advance(); // eat {
final content = _parseChemicalContent(stopAtRightBrace: true);
if (tokenStream.peek() is RightBraceToken) {
tokenStream.advance(); // eat }
}
return GroupNode(content);
} else {
// If there are no {}, then parse only the next token (less common, but compatible with standard LaTeX command behavior)
// However, \ce typically requires {} because the internal syntax is complex.
// Simple handling: If it's just a single token, try to parse it
final content = _parseChemicalContent(
stopAtRightBrace: false,
singleToken: true,
);
return GroupNode(content);
}
}