parseCommand method

LatexNode? parseCommand(
  1. String cmdName
)

Parses a command

Implementation

LatexNode? parseCommand(String cmdName) {
  // HLog.d(_tag, "解析命令: \\$cmdName");

  // 1. Prioritize checking custom commands
  final customCmd = context.customCommands[cmdName];
  if (customCmd != null) {
    return _expandCustomCommand(customCmd);
  }

  // 2. Delegate to registry dispatch
  final registryResult = _registry.dispatch(cmdName, context, tokenStream);
  if (registryResult != null) {
    return registryResult;
  }

  // 3. Chemical formulas (requires chemicalParser instance, unsuitable for generic handlers)
  if (cmdName == "ce" || cmdName == "cf") {
    return chemicalParser.parseChemicalArgument();
  }

  // 4. Fallback: Symbol lookup or generic command
  return _parseSymbolOrGenericCommand(cmdName);
}