From 8e2fbe9dc5fcf67d5ca7a860d9825926c657f2cb Mon Sep 17 00:00:00 2001 From: Michael Witrant Date: Mon, 4 Apr 2011 20:47:29 +0200 Subject: [PATCH] debut wiki --- convert | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/convert b/convert index c7eab23..423e60d 100755 --- a/convert +++ b/convert @@ -18,9 +18,10 @@ data = File.read('Amdts_spectre_1.txt') require 'rubygems' require 'pp' require 'nokogiri' +require 'unindent' sections = data.scan(%r(.+?)m) -amendements = sections.map do |xml| +sections.each do |xml| doc = Nokogiri::XML(xml) num, note = doc.css('NumAm').text.split(' ', 2) @@ -34,7 +35,7 @@ amendements = sections.map do |xml| when "++" "red" when "+" - "lightred" + "IndianRed" when "" "lightgrey" else @@ -54,15 +55,36 @@ amendements = sections.map do |xml| amendement_rows << amendement end - { - :num => num, - :note => note, - :color => color, - :members => doc.css('Members').text, - :article => doc.css('Article').text, - :commission_rows => commission_rows, - :amendement_rows => amendement_rows, - } + commission_rows, amendement_rows = [commission_rows, amendement_rows].map do |rows| + rows.delete_if { |row| row.nil? or row.empty? } + rows.join("\n") + end + + members = doc.css('Members').text + article = doc.css('Article').text + + puts <<-TEXT.unindent + == Amendement #{num} == + {| border="1" style="border-spacing:0;" cellpadding="3" + |- + ! colspan="2" style="background-color: #{color};" | + Amendement #{num} +
+ #{article} +
+ #{members} +
+ #{note} + |- + | + #{commission_rows} + || + #{amendement_rows} + |- + | colspan="2" | + + |} + + TEXT end -puts amendements.to_yaml -- GitLab