* Returns an HTML string with marked text for the matches
(label: string | null)
| 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 |
no test coverage detected