From: Adam Holloway Date: 2012-06-27T19:12:25+09:00 Subject: Copying text from MS Word and wrapping in HTML - help please Hi, I'm new to Ruby and was wondering if someone can help me out with this. I build websites on a daily basis and use HTML all the time, but seem to receive content people want publishing in Word documents all the time and have to simply wrap text in paragraph tags, put ul tags around unordered lists and various other simple and repetitive tasks. Therefore I gather I could use Ruby to do some of these tedious tasks for me, but not sure how to do this. I've made a start, but doesn't seem to work. The one thing I'm really unsure of how to do is to recognise where paragraphs and lists start and end in order to wrap the HTML around it. Any help would be appreciated. require 'rubygems' require 'win32/clipboard' include Win32 # get the text from the clipboard text = Clipboard.data # clean up and wrap in HTML text = text.gsub(/(“|”|£|sometext|• List item 1)/) do |match| case match when '“': '"e' when '”': '"e' when '£': '£' when 'sometext': '

sometext

' when '• List item 1 • List item 2': '' end # send it back to the clipboard Clipboard.set_data(text) # displays message print "Cleaning up clipboard..." Thanks in advance. -- Posted via http://www.ruby-forum.com/.