Skip to content

Instantly share code, notes, and snippets.

@teeparham
Last active December 5, 2024 06:54
Show Gist options
  • Save teeparham/8a99e308884e1c32735a to your computer and use it in GitHub Desktop.
Save teeparham/8a99e308884e1c32735a to your computer and use it in GitHub Desktop.
Convert rdoc to markdown
require 'rdoc'
converter = RDoc::Markup::ToMarkdown.new
rdoc = File.read(ARGV[0] || 'README.rdoc')
puts converter.convert(rdoc)
# ruby rdoc2md.rb > README.md
# ruby rdoc2md.rb ABC.rdoc > abc.md
alias rdoc2md='ruby ~/.ruby/rdoc2md.rb $1'
# rdoc2md > README.md
# rdoc2md ABC.rdoc > ABC.md
@atz
Copy link

atz commented Oct 29, 2015

One liner:

ruby -r rdoc -e 'puts RDoc::Markup::ToMarkdown.new.convert File.read(ARGV[0] || "README.rdoc")' >README.md

@nisanthchunduru
Copy link

nisanthchunduru commented Jun 21, 2017

@atz Thanks for the one liner!

@michaelbrawn
Copy link

Thanks! I didn't get a perfect conversion, but it may have just been poor rdoc formatting to begin with.

@kojix2
Copy link

kojix2 commented Jan 29, 2019

@atz Thanks!

@tunggnu
Copy link

tunggnu commented Dec 25, 2020

@atz Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment