{"id":6852,"library":"redlines","title":"Redlines","description":"Redlines is a Python library that compares two strings or blocks of text, producing human-readable differences or 'deltas' similar to Microsoft Word's track changes. It provides structured output showing detailed change information, positions, and statistics, supporting various formats like JSON (default for CLI), Markdown, HTML, and rich terminal display. The current version is 0.6.1, and the project exhibits an active release cadence.","status":"active","version":"0.6.1","language":"en","source_language":"en","source_url":"https://github.com/houfu/redlines","tags":["text comparison","diff","track changes","markdown","html","json","cli","ai-agents"],"install":[{"cmd":"pip install redlines","lang":"bash","label":"Standard Install"},{"cmd":"pip install redlines[nupunkt]","lang":"bash","label":"With advanced sentence detection (Python 3.11+)"},{"cmd":"pip install redlines[levenshtein]","lang":"bash","label":"With Levenshtein distance statistics"}],"dependencies":[{"reason":"Runtime environment","package":"python","version":">=3.10"},{"reason":"Optional: Advanced sentence detection","package":"nupunkt","version":">=1.0.0","optional":true},{"reason":"Optional: Levenshtein distance statistics","package":"python-Levenshtein","optional":true}],"imports":[{"symbol":"Redlines","correct":"from redlines import Redlines"}],"quickstart":{"code":"from redlines import Redlines\n\nold_text = \"The quick brown fox jumps over the lazy dog.\"\nnew_text = \"The quick brown fox walks past the lazy cat.\"\n\n# Create a Redlines object\ncomparator = Redlines(old_text, new_text)\n\n# Get markdown output with <del>/<ins> tags\nmarkdown_output = comparator.output_markdown\nprint(f\"Markdown Output:\\n{markdown_output}\\n\")\n\n# Get JSON output (structured data)\njson_output = comparator.output_json()\nprint(f\"JSON Output:\\n{json_output}\\n\")\n\n# Example of using the compare method for multiple comparisons\nalternate_new_text = \"The quick brown fox sleeps near the lazy dog.\"\ncompare_output = comparator.compare(alternate_new_text)\nprint(f\"Comparison with alternate text:\\n{compare_output}\")","lang":"python","description":"Instantiate the `Redlines` class with two strings to compare. The class provides methods like `output_markdown`, `output_json`, and `output_rich` for different output formats. The `compare` method can be used for subsequent comparisons against the initial 'old' text."},"warnings":[{"fix":"Review the official 'Agent Integration Guide' or run `redlines --help` for the new CLI syntax. Expect JSON output by default when calling `redlines \"old text\" \"new text\"`.","message":"The command-line interface (CLI) behavior changed significantly in v0.6.0. It is now command-less by default and outputs JSON. Previous versions might have had different default outputs or required specific subcommands.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Verify the PyPI page and documentation to confirm `redlines` (pypi.org/project/redlines) is the correct library for generic text comparison, not `.docx` files.","message":"This `redlines` library is for comparing general text strings. There is a similarly named, but distinct, `Python-Redlines` project (not on PyPI) focused specifically on `.docx` file comparison. Ensure you are installing the correct library for your use case.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install the library with the appropriate extra, e.g., `pip install redlines[nupunkt]` to access `NupunktProcessor` for advanced tokenization.","message":"Advanced features like intelligent sentence detection (for Python 3.11+) and Levenshtein distance statistics require installing optional dependencies using `pip install redlines[nupunkt]` or `pip install redlines[levenshtein]` respectively. These features are not available with a basic `pip install redlines`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}