Monday, June 26, 2006

Re-writing and copying HTML files with Ruby

A personal goal of mine is to read through the Bible this year on a daily basis. To assist me in this I have an HTML file for each month of the year with links that call a JavaScript function passing the text-section value and then putting the value into a URL QueryString and opening a new window with the loaded URL. This worked OK but because the JavaScript opens a new window, the daily links were not showing with the visited style that I set in the CSS file. Here is where Ruby came in.

I thought about just rewriting the HTML but having to create 12 separate files, one for each month, was not what I wanted to do. Why not, as I am learning to use Ruby, use it to parse the existing HTML into a new file, a txt file in this case and then run script to rename the new into the old files, with links that use the traditional target attribute to open a new browser.

Click here to see what I did to parse the existing HTML files into TXT files.

Click here to see the copy of the TXT into HTML files.

No comments: