MCPcopy Create free account
hub / github.com/denoland/std / parseQuotedLiteral

Function parseQuotedLiteral

xml/_parse_sync.ts:518–540  ·  view source on GitHub ↗

* Parse a quoted literal (single or double quoted). * @param validatePubid If true, validate as PubidLiteral per XML 1.0 §2.3

(validatePubid = false)

Source from the content-addressed store, hash-verified

516 * @param validatePubid If true, validate as PubidLiteral per XML 1.0 §2.3
517 */
518 function parseQuotedLiteral(validatePubid = false): void {
519 const quote = input.charCodeAt(pos);
520 if (quote !== CC_DQUOTE && quote !== CC_SQUOTE) {
521 error("Expected quoted string");
522 }
523 const quoteChar = String.fromCharCode(quote);
524 pos++;
525 const valueStart = pos;
526 while (pos < len && input.charCodeAt(pos) !== quote) {
527 pos++;
528 }
529 if (pos >= len) {
530 error("Unterminated quoted string");
531 }
532 if (validatePubid) {
533 const pubidError = validatePubidLiteral(
534 input.slice(valueStart, pos),
535 quoteChar,
536 );
537 if (pubidError) error(pubidError);
538 }
539 pos++;
540 }
541
542 /**
543 * Parse DTD declaration content with whitespace validation.

Callers 1

parseEntityDeclarationFunction · 0.85

Calls 3

validatePubidLiteralFunction · 0.90
errorFunction · 0.85
sliceMethod · 0.45

Tested by

no test coverage detected