require "redcarpet" require "pygments" require_relative "../helpers" class Redcarpet::Render::HTML def header(title, level) anchor = Helpers.clean(title) return <<-eos #{title} eos end # Hacks to get markdown working inside html blocks .... def block_html(html) html.gsub(/([\d\D]+?)<\/markdown>/) {|_| extensions = {fenced_code_blocks: true} renderer = Redcarpet::Markdown.new(WithHighlights, extensions) renderer.render(Regexp.last_match[1]) } end def link(link, title, content) if link == "unfinished-article" return <<-eos
This article is partially or completely unfinished. You are welcome to create pull requests to help completing this article.
eos elsif link == "." if content =~ /#\d+/ url = "https://github.com/petkaantonov/bluebird/issues/" + content[1..-1] else url = "/docs/api/" + Helpers.clean(content) + ".html" end return "#{content}" else return "#{content}" end end end class WithHighlights < Redcarpet::Render::HTML def block_code(code, language) Pygments.highlight(code, :lexer => language) end end