How to use the difflib.ndiff function in difflib

To help you get started, we’ve selected a few difflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zulip / zulip / frontend_tests / zjsunit / mdiff.js View on Github external
function diff_strings(string_0, string_1) {
    let output_lines = [];
    let ndiff_output = "";
    let changes_list = [];

    ndiff_output = difflib.ndiff(string_0.split("\n"), string_1.split("\n"));

    ndiff_output.forEach((line) => {
        if (line.startsWith("+")) {
            output_lines.push(line);
        } else if (line.startsWith("-")) {
            output_lines.push(line);
        } else if (line.startsWith("?")) {
            changes_list = parse_questionmark_line(line);
            output_lines[output_lines.length - 1] = apply_color(
                output_lines[output_lines.length - 1], changes_list);
        } else {
            output_lines.push(line);
        }
    });

    const emphasize_codes = (string) => {

difflib

text diff library ported from Python's difflib module

Unknown
Latest version published 12 years ago

Package Health Score

53 / 100
Full package analysis