MCPcopy Index your code
hub / github.com/danvk/webdiff / codesToHtml

Function codesToHtml

ts/codediff/char-diffs.ts:171–182  ·  view source on GitHub ↗
(mapper: htmlTextMapper, codes: CharacterDiff[])

Source from the content-addressed store, hash-verified

169// codes are (span class, start, end) triples.
170// This wraps html[start..end] in appropriate <span>..</span>s.
171export function codesToHtml(mapper: htmlTextMapper, codes: CharacterDiff[]) {
172 let html = '';
173 for (const [type, start, limit] of codes) {
174 const thisHtml = mapper.getHtmlSubstring(start, limit);
175 if (type == null) {
176 html += thisHtml;
177 } else {
178 html += '<span class="char-' + type + '">' + thisHtml + '</span>';
179 }
180 }
181 return html;
182}

Callers 2

addCharacterDiffsFunction · 0.85

Calls 1

getHtmlSubstringMethod · 0.80

Tested by

no test coverage detected