_diff

in src/_plugins/code_diff_core.rb [39:56]


    def _diff(unified_diff_text, args)
      _log_puts ">> Diff input:\n#{unified_diff_text}" if @log_diffs
      begin
        o, e, _s = Open3.capture3('npx diff2html --su hidden -i stdin -o stdout',
                                  stdin_data: unified_diff_text)
        _log_puts e if e.length > 0
      rescue Errno::ENOENT => _e
        raise "** ERROR: diff2html isn't installed or could not be found. " \
            'To install with NPM run: npm install -g diff2html-cli'
      end
      doc = Nokogiri::HTML(o)
      doc.css('div.d2h-file-header span.d2h-tag').remove
      diff_html = doc.search('.d2h-wrapper')
      _trim_diff(diff_html, args) if args[:from] || args[:to]
      _log_puts "Diff output:\n#{diff_html.to_s[0, [diff_html.to_s.length, 100].min]}...\n" if @log_diffs
      diff_html.to_s
    end