370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
# File 'lib/slaw/za/act_nodes.rb', line 370
def to_xml(b, idprefix, i=0)
text = self.text_value.strip.gsub(/^[ \t]+/, '')
html = WikiCloth::Parser.new({data: text}).to_html
html = Nokogiri::HTML(html)
table = html.css("table").first
table['id'] = "#{idprefix}table#{i}"
table.css("td, th").each do |cell|
p = Nokogiri::XML::Node.new("p", html)
p.children = cell.children
p.parent = cell
p.search("text()").each do |text|
lines = text.content.strip.split(/\n/)
text.content = lines.shift
for line in lines
eol = text.add_next_sibling(Nokogiri::XML::Node.new("eol", html))
text = eol.add_next_sibling(Nokogiri::XML::Text.new(line, html))
end
end
end
table.xpath('//text()[1]').each{ |t| t.content = t.content.lstrip }
table.xpath('//text()[last()]').each{ |t| t.content = t.content.rstrip }
b.parent << table
end
|