beginrequire"linguist"rescueLoadError# Rely on extensions instead.endrequire"github/markup/command_implementation"require"github/markup/gem_implementation"moduleGitHubmoduleMarkups# all of supported markups:MARKUP_ASCIIDOC=:asciidocMARKUP_CREOLE=:creoleMARKUP_MARKDOWN=:markdownMARKUP_MEDIAWIKI=:mediawikiMARKUP_ORG=:orgMARKUP_POD=:podMARKUP_RDOC=:rdocMARKUP_RST=:rstMARKUP_TEXTILE=:textileMARKUP_POD6=:pod6endmoduleMarkupextendself@@markups={}defmarkups@@markupsenddefmarkup_implsmarkups.valuesenddefpreload!markup_impls.each(&:load)enddefrender(filename,content,symlink: false,options: {})if(impl=renderer(filename,content,symlink: symlink))impl.render(filename,content,options: options)elsecontentendenddefrender_s(symbol,content,options: {})raiseArgumentError,'Can not render a nil.'ifcontent.nil?ifmarkups.key?(symbol)markups[symbol].render(nil,content,options: options)elsecontentendenddefmarkup(symbol,gem_name,regexp,languages,opts={},&block)impl=GemImplementation.new(regexp,languages,gem_name,&block)markup_impl(symbol,impl)enddefmarkup_impl(symbol,impl)ifmarkups.key?(symbol)raiseArgumentError,"The '#{symbol}' symbol is already defined."endmarkups[symbol]=implenddefcommand(symbol,command,regexp,languages,name,&block)ifFile.exist?(file=File.dirname(__FILE__)+"/commands/#{command}")command=fileendimpl=CommandImplementation.new(regexp,languages,command,name,&block)markup_impl(symbol,impl)enddefcan_render?(filename,content,symlink: false)renderer(filename,content,symlink: symlink)!=nilenddefrenderer(filename,content,symlink: false)language=language(filename,content,symlink: symlink)markup_impls.finddo|impl|impl.match?(filename,language)endenddeflanguage(filename,content,symlink: false)returnunlessdefined?(::Linguist)blob=Linguist::Blob.new(filename,content,symlink: symlink)Linguist.detect(blob,allow_empty: true)end# Define markupsmarkups_rb=File.dirname(__FILE__)+'/markups.rb'instance_evalFile.read(markups_rb),markups_rbendend