const showNumber = (lineInfo) => { const first = lineInfo.line[0]; return first === ' ' || first === '@' || first === '-' || first === '+'; } let htmlEncode const construct = (data) => { const diffs = data.diffs for(let diffLineIndex in diffs.lines) { diffs.lines[diffLineIndex].line = htmlEncode(diffs.lines[diffLineIndex].line) } let result = `
Old | ${diffs.old} | |
New | ${diffs.new} | |
${showNumber(lineInfo) ? lineInfo['num-old'] : ' '} | ${showNumber(lineInfo) ? lineInfo['num-new'] : ' '} |
${lineInfo.line} |