Created
May 21, 2010 18:25
-
-
Save eqdw/409212 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@in_item = false #are we in channel or item? | |
@link = [] #current link. becuase links and texts go together | |
line = gets | |
while(line) | |
if line =~ /<item>/ | |
puts "<h2><a href=#{@link[0]}>#{escape(@link[1])}<\/a><\/h2>" | |
@in_item = true | |
elsif line =~ /<\/item>/ | |
puts "<a href=#{@link[0]}>#{escape(@link[1])}<\/a>" | |
@link = [nil, nil] | |
@in_item = false; | |
end | |
if @in_item | |
if line =~ /<title>(.*)<\/title>/ | |
puts "<h3>#{escape($1)}<\/h3>" | |
elsif line =~ /<link>(.*)<\/link>/ | |
@link[0] = $1 | |
elsif line =~ /<description>(.*)<\/description>/ | |
@link[1] = $1 | |
end | |
else | |
if line =~ /<title>(.*)<\/title>/ | |
puts "<h1>#{escape($1)}<\/h1>" | |
elsif line =~ /<link>(.*)<\/link>/ | |
@link[0] = $1 | |
elsif line =~ /<description>(.*)<\/description>/ | |
@link[1] = %1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment