Guest User

Untitled

a guest
Jan 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #Convert your feedly OPML file to a markdown file
  2. #Usage:
  3. #ruby opml_to_markdown.rb FEEDLY_OPML_PATH
  4.  
  5. require 'nokogiri'
  6.  
  7. markdownContent = ""
  8. opmlFile = File.open(ARGV[0])
  9. opmlDoc = Nokogiri::XML(opmlFile)
  10. markdownName = opmlDoc.xpath('//head/title').text
  11.  
  12. opmlDoc.xpath('//body/outline').each do |dirOutline|
  13. markdownContent << "\n" + "###" + dirOutline.attr('title') + "\n"
  14.  
  15. dirOutline.children.each do |rss|
  16. markdownContent << "* [%s](%s)\n" % [rss.attr('title'),rss.attr('xmlUrl')] unless rss.to_s.include? "\n"
  17. end
  18. end
  19.  
  20. File.open("#{markdownName}.md","w+") { |file| file << markdownContent}
Add Comment
Please, Sign In to add comment