Skip to content

Instantly share code, notes, and snippets.

@muyexi
Last active January 9, 2018 22:15
Show Gist options
  • Save muyexi/2270d5046020cac9a6c1 to your computer and use it in GitHub Desktop.
Save muyexi/2270d5046020cac9a6c1 to your computer and use it in GitHub Desktop.
Convert your feedly OPML file to a markdown file
#Convert your feedly OPML file to a markdown file
#Usage:
#ruby opml_to_markdown.rb FEEDLY_OPML_PATH
require 'nokogiri'
markdownContent = ""
opmlFile = File.open(ARGV[0])
opmlDoc = Nokogiri::XML(opmlFile)
markdownName = opmlDoc.xpath('//head/title').text
opmlDoc.xpath('//body/outline').each do |dirOutline|
markdownContent << "\n" + "###" + dirOutline.attr('title') + "\n"
dirOutline.children.each do |rss|
markdownContent << "* [%s](%s)\n" % [rss.attr('title'),rss.attr('xmlUrl')] unless rss.to_s.include? "\n"
end
end
File.open("#{markdownName}.md","w+") { |file| file << markdownContent}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment