MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / tokenize

Function tokenize

src/compute-engine/latex-syntax/tokenizer.ts:402–423  ·  view source on GitHub ↗
(s: string, args: string[] = [])

Source from the content-addressed store, hash-verified

400 tokenize(argMap?.[param] ?? argMap?.['?'] ?? '\\placeholder{}', args)
401 );
402 } else {
403 result.push(token);
404 }
405
406 return result;
407}
408
409/**
410 * Create Tokens from a stream of LaTeX
411 *
412 * @param s - A string of LaTeX. It can include comments (with the `%`
413 * marker) and multiple lines.
414 */
415export function tokenize(
416 s: string,
417 args: string[] = [],
418 comments?: DiscardedComment[]
419): Token[] {
420 // Merge multiple lines into one, and remove comments.
421 // Split keeping the line separators (capture group) so the exact separator
422 // length — `\n` (1) or `\r\n` (2) — advances the original-input offset used
423 // to report discarded-comment spans. `parts` alternates line, separator,
424 // line, separator, …; even indices are lines, odd indices are the following
425 // separator (or `undefined` for the last line).
426 const str = s.toString();

Callers 8

tokenizer.test.tsFile · 0.90
constructorMethod · 0.90
parseCoreFunction · 0.90
addEntryFunction · 0.90
makeIndexedEntryFunction · 0.90
expandFunction · 0.85
countTokensFunction · 0.85

Calls 4

endMethod · 0.95
expandFunction · 0.70
toStringMethod · 0.65
matchMethod · 0.65

Tested by

no test coverage detected