| 405 | // this is the character comparison logic that performs the 'largest common |
| 406 | // subsequence' between two lines of code |
| 407 | charcomp = function diffview_report_charcomp(lineA:string, lineB:string): [string, string]{ |
| 408 | let b: number = 0, |
| 409 | currentdiff = [], |
| 410 | dataMinLength: number = 0, |
| 411 | dataA: string[] = [], |
| 412 | dataB: string[] = []; |
| 413 | const cleanedA: string = (options.diff_format === "text") |
| 414 | ? lineA |
| 415 | : lineA |
| 416 | .replace(/ /g, " ") |
| 417 | .replace(/ /g, " ") |
| 418 | .replace(/</g, "<") |
| 419 | .replace(/>/g, ">") |
| 420 | .replace(/\$#lt;/g, "<") |
| 421 | .replace(/\$#gt;/g, ">") |
| 422 | .replace(/&/g, "&"), |
| 423 | cleanedB: string = (options.diff_format === "text") |
| 424 | ? lineB |
| 425 | : lineB |
| 426 | .replace(/ /g, " ") |
| 427 | .replace(/ /g, " ") |
| 428 | .replace(/</g, "<") |
| 429 | .replace(/>/g, ">") |
| 430 | .replace(/\$#lt;/g, "<") |
| 431 | .replace(/\$#gt;/g, ">") |
| 432 | .replace(/&/g, "&"), |
| 433 | regStart: RegExp = (/_pdiffdiff\u005f/g), |
| 434 | regEnd: RegExp = (/_epdiffdiff\u005f/g), |
| 435 | strStart: string = "_pdiffdiff\u005f", |
| 436 | strEnd: string = "_epdiffdiff\u005f", |
| 437 | tabdiff: [string, string, string, string] = (function diffview_report_charcomp_tabdiff(): [string, string, string, string]{ |
| 438 | let tabMatchA: string = "", |
| 439 | tabMatchB: string = "", |
| 440 | splitA: string = "", |
| 441 | splitB: string = "", |
| 442 | matchListA: string[] | null = cleanedA.match(tabFix), |
| 443 | matchListB: string[] | null = cleanedB.match(tabFix); |
| 444 | if (matchListA === null || matchListB === null || (matchListA[0] === "" && matchListA.length === 1) || (matchListB[0] === "" && matchListB.length === 1)) { |
| 445 | return ["", "", cleanedA, cleanedB]; |
| 446 | } |
| 447 | tabMatchA = matchListA[0]; |
| 448 | tabMatchB = matchListB[0]; |
| 449 | splitA = cleanedA.split(tabMatchA)[1]; |
| 450 | splitB = cleanedB.split(tabMatchB)[1]; |
| 451 | if (tabMatchA.length > tabMatchB.length) { |
| 452 | tabMatchA = tabMatchA.slice(0, tabMatchB.length) + strStart + tabMatchA.slice(tabMatchB.length) + strEnd; |
| 453 | } else { |
| 454 | tabMatchB = tabMatchB.slice(0, tabMatchA.length) + strStart + tabMatchB.slice(tabMatchA.length) + strEnd; |
| 455 | } |
| 456 | return [tabMatchA, tabMatchB, splitA, splitB]; |
| 457 | }()), |
| 458 | whiteout = function diffview_report_charcomp_whiteout(whitediff : string): string { |
| 459 | const spacetest: RegExp = (/<((em)|(pd))>\u0020+<\/((em)|(pd))>/), |
| 460 | crtest: RegExp = (/<((em)|(pd))>\r+<\/((em)|(pd))>/); |
| 461 | if (spacetest.test(whitediff) === true) { |
| 462 | return whitediff; |
| 463 | } |
| 464 | if (crtest.test(whitediff) === true) { |