Commit 7062a384 authored by Michael Witrant's avatar Michael Witrant

utilise htmldiff

parent 94a6ab18
#!/usr/bin/env ruby
# Pour lancer le script il faut ruby, rubygems et les gems nokogiri et differ
# Pour lancer le script il faut ruby, rubygems et les gems nokogiri et htmldiff
require 'rubygems'
require 'nokogiri'
require 'differ'
require 'htmldiff'
require 'erb'
data = %w(3 1 2).map { |i| File.read("Amdts_spectre_#{i}.txt") }.join
......@@ -12,7 +12,7 @@ sections = data.scan(%r(<Amend>.+?</Amend>)m)
Amendment = Struct.new :num, :note, :color, :commission_rows, :amendement_rows, :members, :article
Differ.format = :html
include HTMLDiff
class Amendment
Template = ERB.new File.read('template.erb'), nil, '-'
......@@ -59,9 +59,8 @@ amendments = sections.map do |xml|
infos.each_slice(2) do |commission, amendment|
commission = commission.to_s
amendment = amendment.to_s
#p [commission, amendment, Differ.diff_by_char(amendment, commission).to_s]
commission_rows << Differ.diff_by_char(commission, amendment).to_s
amendement_rows << Differ.diff_by_char(amendment, commission).to_s
commission_rows << diff(commission, amendment).to_s.gsub(%r(<ins class=".+?">.+?</ins>), "").gsub(%r(<del class=".+?">(.+?)</del>), "'''\\1'''")
amendement_rows << diff(commission, amendment).to_s.gsub(%r(<del class=".+?">.+?</del>), "").gsub(%r(<ins class=".+?">(.+?)</ins>), "'''\\1'''")
end
members = doc.css('Members').text
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment