2

I'm having what I think is a load ordering issue using github-markup.

I'm trying to override the default markdown renderers and use my own custom renderer in a Rails initializer. However it doesn't work; it just seems to ignore my initializer unless I specifically include the githum-markup gem in my Gemfile and specify add the :git or :path setting. (github-markup is a dependancy for the gollum gem)

Gemfile

## Github-Markup #######
# Initializer wiki.rb wont work properly unless this gem is loaded via path: or git:
gem 'github-markup', :git => 'git://github.com/github/markup.git'

gem 'gollum' #gollum already includes github-markup so I shouldn't need the lines above

initializers/wiki.rb

GitHub::Markup.add_markup(/md|mkdn?|mdwn|mdown|markdown/) do |content|
  CustomMarkdown.new(content).to_html
end

Looking at the github-markup code the class calls the markups near the bottom of this file:

https://github.com/github/markup/blob/master/lib/github/markup.rb

instance_eval File.read(File.dirname(__FILE__) + '/markups.rb')

And you can see the markdown renderers I'm trying to override at the top of this file:

https://github.com/github/markup/blob/master/lib/github/markups.rb

MD_FILES = /md|mkdn?|mdwn|mdown|markdown/

if markup('github/markdown', MD_FILES) do |content|
    GitHub::Markdown.render(content)
  end
elsif markup(:redcarpet, MD_FILES) do |content|
    RedcarpetCompat.new(content).to_html
  end
elsif markup(:rdiscount, MD_FILES) do |content|
    RDiscount.new(content).to_html
  end
elsif markup(:maruku, MD_FILES) do |content|
    Maruku.new(content).to_html
  end
elsif markup(:kramdown, MD_FILES) do |content|
    Kramdown::Document.new(content).to_html
  end
elsif markup(:bluecloth, MD_FILES) do |content|
    BlueCloth.new(content).to_html
  end
end

Just to be clear I'm using Ruby 1.9.3 and I'd like to get it so I can just call gem 'gollum' in the Gemfile and use my initializer to override the default github-markup markdown renderer with my own custom renderer.

Luke
  • 1,639
  • 15
  • 16
  • Is this still relevant? If so, what are you trying to achieve... Have Gollum render some custom markup, or just render some Github flavored markdown in a view, or something else? – Thomas Klemm Dec 20 '12 at 17:12
  • Yep still relevant, I've got a workaround for the issue (as described above) but it'd be good to fix this properly. I'm trying to get Gollum to use my own custom markdown renderer (which I can do in a Rails initializer) however I can only do this if specifically include github-markup in my Gemfile with the :git or :path command. – Luke Dec 21 '12 at 07:22

0 Answers0