Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This is not a final PR #103

Merged
merged 2 commits into from Mar 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 9 additions & 14 deletions Rakefile
Expand Up @@ -3,15 +3,9 @@ require 'rake/clean'
require 'rdoc/encoding'
require 'rdoc/markup/to_html'
require 'redcarpet'
require 'rouge'
require 'rouge/plugins/redcarpet'
require 'uri'
require 'nokogiri'


class HTML < Redcarpet::Render::HTML
include Rouge::Plugins::Redcarpet # yep, that's it.
end
require 'kramdown'


def cleanup(html)
Expand Down Expand Up @@ -72,7 +66,7 @@ end
task :default => ['_sinatra', '_contrib', :build]

desc "Build outdated static files and API docs"
task :build => ['build:static']
task :build => [:pull, 'build:static']

desc "Build outdated static files"
task 'build:static' => readme("_includes/%s.html") + contrib("_includes/%s.html")
Expand Down Expand Up @@ -109,16 +103,17 @@ task 'pull:contrib' => "_contrib" do
sh "cd _contrib && git pull &>/dev/null"
end

readme("_sinatra/%s") { |fn| file fn => '_sinatra' }
readme("_sinatra/%s.md") { |fn| file fn => '_sinatra' }
file 'AUTHORS' => '_sinatra'


readme do |fn|
file "_includes/#{fn}.html" => ["_sinatra/#{fn}", "Rakefile"] do |f|
rndr = HTML.new(:safe_links_only => true)
markdown = Redcarpet::Markdown.new(rndr, :lax_spacing => true, :fenced_code_blocks => true)
file "_includes/#{fn}.html" => ["_sinatra/#{fn}.md", "Rakefile"] do |f|
markdown_string = File.read("_sinatra/#{fn}.md").encode('UTF-16le', :invalid => :replace, :replace => "").encode("UTF-8")
html = cleanup(markdown.render(markdown_string))
markdown_string.gsub!(/```(\s?(\w+\n))?/) do |match|
match =~ /```\s?\n/ ? "~~~~~\n" : match.sub(/```\s?/, "~~~~")
end
markdown = Kramdown::Document.new(markdown_string, :fenced_code_blocks => true, :coderay_line_numbers => nil, :auto_ids => false)
html = cleanup(markdown.to_html)
File.open(f.name, 'w') { |io| io.write with_toc(html) }
end
end
Expand Down