MCPcopy Create free account
hub / github.com/LibPDF-js/core / tokenize

Method tokenize

src/fontbox/afm/parser.ts:513–540  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

511 }
512
513 private tokenize(line: string): string[] {
514 // Split on whitespace and semicolons, keeping semicolons as tokens
515 const tokens: string[] = [];
516 let current = "";
517
518 for (const char of line) {
519 if (char === " " || char === "\t") {
520 if (current) {
521 tokens.push(current);
522 current = "";
523 }
524 } else if (char === ";") {
525 if (current) {
526 tokens.push(current);
527 current = "";
528 }
529 tokens.push(";");
530 } else {
531 current += char;
532 }
533 }
534
535 if (current) {
536 tokens.push(current);
537 }
538
539 return tokens;
540 }
541
542 private verifySemicolon(tokens: string[], index: number): void {
543 if (index >= tokens.length) {

Callers 2

parseCharMetricMethod · 0.95
parseCompositeMethod · 0.95

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected