Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Compare text, and produce human-readable differences or deltas which look like track changes in Microsoft Word.
Redlines
produces a text showing the differences between two strings/text. The changes are represented with
strike-throughs and underlines, which looks similar to Microsoft Word's track changes. This method of showing changes is
more familiar to lawyers and is more compact for long series of characters.
Redlines uses SequenceMatcher
to find differences between words used.
The output can be in HTML, Markdown, or rich
format.
Given an original string:
The quick brown fox jumps over the lazy dog.
And the string to be tested with:
The quick brown fox walks past the lazy dog.
The library gives a result of:
The quick brown fox <del>jumps over </del><ins>walks past </ins>the lazy dog.
Which is rendered like this:
The quick brown fox
jumps overwalks past the lazy dog.
The library can also output the results in Markdown, HTML or rich
format, and
for a variety of environments like Streamlit, Jupyter Notebooks, Google Colab and the terminal.
pip install redlines
The library contains one class: Redlines
, which is used to compare text.
from redlines import Redlines
test = Redlines(
"The quick brown fox jumps over the lazy dog.",
"The quick brown fox walks past the lazy dog.", markdown_style="none",
)
assert (
test.output_markdown
== "The quick brown fox <del>jumps over </del><ins>walks past </ins>the lazy dog."
)
Alternatively, you can create Redline with the text to be tested, and compare several times to see the results.
from redlines import Redlines
test = Redlines("The quick brown fox jumps over the lazy dog.", markdown_style="none")
assert (
test.compare("The quick brown fox walks past the lazy dog.")
== "The quick brown fox <del>jumps over </del><ins>walks past </ins>the lazy dog."
)
assert (
test.compare("The quick brown fox jumps over the dog.")
== "The quick brown fox jumps over the <del>lazy </del>dog."
)
Redlines also features a simple command line tool redlines
to visualise the differences in text in the terminal.
Usage: redlines text [OPTIONS] SOURCE TEST
Compares the strings SOURCE and TEST and produce a redline in the terminal.
You may also want to check out the demo project redlines-textual.
Read the available Documentation.
MIT License
FAQs
Compare text, and produce human-readable differences or deltas which look like track changes in Microsoft Word.
We found that redlines demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.