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

Function joinLatex

src/compute-engine/latex-syntax/tokenizer.ts:429–446  ·  view source on GitHub ↗
(segments: Iterable<string>)

Source from the content-addressed store, hash-verified

427 const parts = str.split(/(\r?\n)/);
428 let stream = '';
429 let sep = '';
430 // Offset of the start of the current line in the original string. Advanced
431 // by the line length plus the actual separator length. Used only to report
432 // the original-input span of discarded comments (code `comment-discarded`).
433 let lineOffset = 0;
434 for (let i = 0; i < parts.length; i += 2) {
435 const line = parts[i];
436 const separator = parts[i + 1] ?? '';
437 stream += sep;
438 sep = ' ';
439 // Remove everything after a % (comment marker)
440 // (but \% should be preserved...)
441 const m = line.match(/((?:\\%)|[^%])*/);
442 if (m !== null) {
443 stream += m[0];
444 // An unescaped `%` was found iff the match is shorter than the line: the
445 // discarded run is `%` through end-of-line, in original-input coordinates.
446 if (comments !== undefined && m[0].length < line.length) {
447 const start = lineOffset + m[0].length;
448 const end = lineOffset + line.length;
449 comments.push({

Callers 15

core.tsFile · 0.90
latexTemplateFunction · 0.90
asLatexStringFunction · 0.90
serializeMultiplyFunction · 0.90
serializeBigOpFunction · 0.90
serializeSequenceFunction · 0.90
serializeOpsFunction · 0.90
serializeLatexTokensFunction · 0.90

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected