MCPcopy
hub / github.com/microsoft/tsdoc / _parseHtmlString

Method _parseHtmlString

tsdoc/src/parser/NodeParser.ts:1967–2009  ·  view source on GitHub ↗
(tokenReader: TokenReader)

Source from the content-addressed store, hash-verified

1965 }
1966
1967 private _parseHtmlString(tokenReader: TokenReader): ResultOrFailure<string> {
1968 const marker: number = tokenReader.createMarker();
1969 const quoteTokenKind: TokenKind = tokenReader.peekTokenKind();
1970 if (quoteTokenKind !== TokenKind.DoubleQuote && quoteTokenKind !== TokenKind.SingleQuote) {
1971 return this._createFailureForToken(
1972 tokenReader,
1973 TSDocMessageId.HtmlTagMissingString,
1974 'Expecting an HTML string starting with a single-quote or double-quote character'
1975 );
1976 }
1977 tokenReader.readToken();
1978
1979 let textWithoutQuotes: string = '';
1980
1981 for (;;) {
1982 const peekedTokenKind: TokenKind = tokenReader.peekTokenKind();
1983 // Did we find the matching token?
1984 if (peekedTokenKind === quoteTokenKind) {
1985 tokenReader.readToken(); // extract the quote
1986 break;
1987 }
1988 if (peekedTokenKind === TokenKind.EndOfInput || peekedTokenKind === TokenKind.Newline) {
1989 return this._createFailureForToken(
1990 tokenReader,
1991 TSDocMessageId.HtmlStringMissingQuote,
1992 'The HTML string is missing its closing quote',
1993 marker
1994 );
1995 }
1996 textWithoutQuotes += tokenReader.readToken().toString();
1997 }
1998
1999 // The next attribute cannot start immediately after this one
2000 if (tokenReader.peekTokenKind() === TokenKind.AsciiWord) {
2001 return this._createFailureForToken(
2002 tokenReader,
2003 TSDocMessageId.TextAfterHtmlString,
2004 'The next character after a closing quote must be spacing or punctuation'
2005 );
2006 }
2007
2008 return textWithoutQuotes;
2009 }
2010
2011 private _parseHtmlEndTag(tokenReader: TokenReader): DocNode {
2012 tokenReader.assertAccumulatedSequenceIsEmpty();

Callers 1

_parseHtmlAttributeMethod · 0.95

Calls 5

createMarkerMethod · 0.80
peekTokenKindMethod · 0.80
readTokenMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected