rtfpessoa / diff2html

Pretty diff to html javascript library (diff2html)
https://diff2html.xyz
MIT License
2.79k stars 272 forks source link

Blank context lines are ignored by diff parser #485

Closed Lordfirespeed closed 1 year ago

Lordfirespeed commented 1 year ago

Step 0: Describe your environment

Step 1: Describe the problem:

Blank context lines are being ignored by the diff parser

Steps to reproduce:

  1. Parse the diff2html.xyz demo diff
  2. Check the length of the first block of the first parsed file: it should be 9, with blank context lines at 0-indexes 6 and 8

Observed Results:

Expected Results:

Relevant Code:

export default function create_app() {
    const app = express();

    app.set("view engine", "ejs");

    app.get("/", async (request, response) => {
        const diff = await readFile("diffs/diff2htmldemo.diff", "utf-8");
        const parsed_diff = diff2html.parse(diff);
        const formatted_diff = diff2html.html(parsed_diff, {
            drawFileList: true,
            matching: "lines",
            outputFormat: "line-by-line",
        });
        response.render("pages/diff", { diff_tables: formatted_diff })
    });

    app.use("/", express.static("static"));
    app.use("/diff2html-bundles", express.static("node_modules/diff2html/bundles"));

    return app;
}
Lordfirespeed commented 1 year ago

My IDE was removing the important leading whitespace at the beginning of blank context lines. Duh.