Permalink
Browse files

fix markdown rendering

  • Loading branch information...
1 parent 2b3cc18 commit 25624d07de1cfb30b74623acfe1fc681d014079c @rkh rkh committed Mar 10, 2013
Showing with 14,964 additions and 13,185 deletions.
  1. +5 −11 Rakefile
  2. +1,803 −1,426 _includes/README.de.html
  3. +1,900 −1,532 _includes/README.es.html
  4. +1,785 −1,511 _includes/README.fr.html
  5. +1,711 −1,245 _includes/README.html
  6. +534 −508 _includes/README.hu.html
  7. +737 −801 _includes/README.jp.html
  8. +1,990 −1,946 _includes/README.ko.html
  9. +604 −394 _includes/README.pt-br.html
  10. +439 −394 _includes/README.pt-pt.html
  11. +2,217 −2,009 _includes/README.ru.html
  12. +1,236 −1,406 _includes/README.zh.html
  13. +1 −1 _includes/sinatra-cookies.html
  14. +2 −1 _includes/sinatra-streaming.html
View
@@ -84,17 +84,11 @@ desc 'Convert Sinatra READMEs to HTML'
task 'convert:sinatra' do
readme do |fn|
file "_includes/#{fn}.html" => ["_sinatra/#{fn}", "Rakefile"] do |f|
- if %w{es hu jp ko pt-br pt-pt zh}.include?(fn.split(".").last)
- html =
- RDoc::Markup::ToHtml.new.
- convert(RDoc::Encoding.read_file("_sinatra/#{fn}.rdoc", Encoding::UTF_8)).
- sub("<h1>Sinatra</h1>", "")
- else
- rndr = Redcarpet::Render::HTML.new(:safe_links_only => true)
- markdown = Redcarpet::Markdown.new(rndr, :lax_spacing => true, :fenced_code_blocks => true)
- markdown_string = File.read("_sinatra/#{fn}.md").encode('UTF-16le', :invalid => :replace, :replace => "").encode("UTF-8")
- html = markdown.render(markdown_string).sub("<h1>Sinatra</h1>", "")
- end
+ rndr = Redcarpet::Render::HTML.new(:safe_links_only => true)
+ markdown = Redcarpet::Markdown.new(rndr, :lax_spacing => true, :fenced_code_blocks => true)
+ markdown_string = File.read("_sinatra/#{fn}.md").encode('UTF-16le', :invalid => :replace, :replace => "").encode("UTF-8")
+ markdown_string.sub!(/##[^#]*\[Sinatra\]((?!\n#).)+/m, '') # remove ToC
+ html = markdown.render(markdown_string).sub("<h1>Sinatra</h1>", "")
File.open(f.name, 'w') { |io| io.write with_toc(html) }
end
CLEAN.include "_includes/#{fn}.html"
Oops, something went wrong.

0 comments on commit 25624d0

Please sign in to comment.