( beforeText: string, beforeHtml: string, afterText: string, afterHtml: string, )
| 81 | } |
| 82 | |
| 83 | export function addCharacterDiffs( |
| 84 | beforeText: string, |
| 85 | beforeHtml: string, |
| 86 | afterText: string, |
| 87 | afterHtml: string, |
| 88 | ): [string, string] { |
| 89 | const codes = computeCharacterDiffs(beforeText, afterText); |
| 90 | if (codes == null) { |
| 91 | return [beforeHtml, afterHtml]; |
| 92 | } |
| 93 | const [beforeOut, afterOut] = codes; |
| 94 | |
| 95 | // Splice in "insert", "delete" and "replace" tags. |
| 96 | // This is made more difficult by the presence of syntax highlighting, which |
| 97 | // has its own set of tags. The two can co-exists if we're careful to only |
| 98 | // wrap complete (balanced) DOM trees. |
| 99 | const beforeMapper = new htmlTextMapper(beforeText, beforeHtml); |
| 100 | const afterMapper = new htmlTextMapper(afterText, afterHtml); |
| 101 | |
| 102 | return [codesToHtml(beforeMapper, beforeOut), codesToHtml(afterMapper, afterOut)]; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @param {string} line The line to be split |
no test coverage detected