MCPcopy Index your code
hub / github.com/angular/angular / parseLabelToHtml

Method parseLabelToHtml

adev/shared-docs/services/search.service.ts:153–173  ·  view source on GitHub ↗

* Returns an HTML string with marked text for the matches

(label: string | null)

Source from the content-addressed store, hash-verified

151 * Returns an HTML string with marked text for the matches
152 */
153 private parseLabelToHtml(label: string | null): string | null {
154 if (label === null) {
155 return null;
156 }
157
158 const parts: Array<{highlight: boolean; text: string}> = [];
159 while (label.indexOf('<ɵ>') !== -1) {
160 const beforeMatch = label.substring(0, label.indexOf('<ɵ>'));
161 const match = label.substring(label.indexOf('<ɵ>') + 3, label.indexOf('</ɵ>'));
162 parts.push({highlight: false, text: beforeMatch});
163 parts.push({highlight: true, text: match});
164 label = label.substring(label.indexOf('</ɵ>') + 4);
165 }
166 parts.push({highlight: false, text: label});
167
168 return parts
169 .map((part) => {
170 return part.highlight ? `<mark>${part.text}</mark>` : `<span>${part.text}</span>`;
171 })
172 .join('');
173 }
174
175 public searchWithQuery(query: string): Promise<SearchResultItem[] | undefined> {
176 return this.client

Callers 1

parseResultMethod · 0.95

Calls 4

indexOfMethod · 0.80
mapMethod · 0.80
joinMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected