Last active
January 9, 2018 22:15
-
-
Save muyexi/2270d5046020cac9a6c1 to your computer and use it in GitHub Desktop.
Convert your feedly OPML file to a markdown file
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
#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