Compare HTML and Markdown using inline or side-by-side diffs.
The code for this is extracted from Discourse. This just packages it as a standalone gem.
Add this line to your application's Gemfile:
gem 'html_diff', github: 'feedbin/html_diff'
require "html_diff"
# Generate inline HTML diff
HTMLDiff::Diff.new(before, after).inline_html
# Generate side-by-side HTML diff
HTMLDiff::Diff.new(before, after).side_by_side_html
# Generate side-by-side Markdown diff
HTMLDiff::Diff.new(before, after).side_by_side_markdown