Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sms-htmldiff

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sms-htmldiff

  • 0.0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

HTMLdiff

This gem generates nice diff outputs (in HTML) from two supplied bits of HTML which are (presumably) partially different. It is aimed at the limited HTML that one would expect to be outputted from a WYSIWYG editor.

It is not foolproof and only gives good results with a limited (and not fully documented) range of HTML tags. See the specs for stuff that is known to work. Beyond that you're on your own!

Usage

doc_a = 'a word is here'
doc_b = 'a nother word is there'

HTMLDiff.diff(doc_a, doc_b)

# => 'a<ins class=\"diffins\"> nother</ins> word is <del class=\"diffmod\">here</del><ins class=\"diffmod\">there</ins>'

Block tags

If you have some things which need to be treated as one unified lump of HTML that has been added or taken away e.g. an embedded document composed of a div with some images in it, then add class="block_tag" to the opening div tag. The diff will then surround the whole thing with an <ins> or <del> tag, as well as showing the whole thing as replaced with a new version if any of the content changes.

Credits

This is a fork of the htmldiff gem here https://github.com/myobie/htmldiff/ which appears to no longer be maintained. It has been refactored internally and made to be more useful when comparing the diff generated by HTML editors.

FAQs

Package last updated on 26 Apr 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc