debian-mirror-gitlab/vendor/gems/ipynbdiff/lib/ipynbdiff.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
802 B
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
# Human Readable Jupyter Diffs
module IpynbDiff
require 'transformer'
require 'diff'
def self.diff(from, to, raise_if_invalid_nb: false, include_frontmatter: false, hide_images: false, diffy_opts: {})
transformer = Transformer.new(include_frontmatter: include_frontmatter, hide_images: hide_images)
Diff.new(transformer.transform(from), transformer.transform(to), diffy_opts)
rescue InvalidNotebookError
raise if raise_if_invalid_nb
end
def self.transform(notebook, raise_errors: false, include_frontmatter: true, hide_images: false)
return unless notebook
Transformer.new(include_frontmatter: include_frontmatter, hide_images: hide_images).transform(notebook).as_text
rescue InvalidNotebookError
raise if raise_errors
end
end