Skip to content

Instantly share code, notes, and snippets.

@eqdw
Created May 21, 2010 18:25
Show Gist options
  • Save eqdw/409212 to your computer and use it in GitHub Desktop.
Save eqdw/409212 to your computer and use it in GitHub Desktop.
@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