lib/rdoc/generator/markdown.rb in rdoc-markdown-0.1.7 vs lib/rdoc/generator/markdown.rb in rdoc-markdown-0.1.8

- old
+ new

@@ -110,11 +110,11 @@ end end template = ERB.new File.read(File.join(TEMPLATE_DIR, "classfile.md.erb")) - out_file = Pathname.new("#{output_dir}/#{klass.full_name}.md") + out_file = Pathname.new("#{output_dir}/#{turn_to_path klass.full_name}.md") out_file.dirname.mkpath result = template.result(binding) File.write(out_file, result) @@ -122,11 +122,23 @@ end private + def replace_extensions_in_links(text) + text.gsub(/\[(.+)\]\((.+).html(.*)\)/) do |_| + match = Regexp.last_match + + "[#{match[1]}](#{match[2]}.md#{match[3]})" + end + end + + def turn_to_path(class_name) + class_name.gsub("::", "/") + end + def h(string) - ReverseMarkdown.convert string.strip, github_flavored: true + replace_extensions_in_links ReverseMarkdown.convert string.strip, github_flavored: true end def setup return if instance_variable_defined?(:@output_dir)