Permalink
Browse files

Use kramdown instead of maruku

  • Loading branch information...
1 parent 8570539 commit 7b73b7d7eec01aab18326b5f151a160fe9520939 @chischaschos committed Jan 29, 2014
Showing with 17 additions and 49 deletions.
  1. +1 −0 .rspec
  2. +1 −1 Gemfile
  3. +2 −3 Gemfile.lock
  4. +6 −2 README.md
  5. +1 −40 lib/post.rb
  6. +6 −3 spec/post_spec.rb
View
1 .rspec
@@ -0,0 +1 @@
+--color
View
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
ruby '1.9.3'
gem 'haml'
-gem "maruku", "~> 0.6.1"
+gem 'kramdown'
gem 'newrelic_rpm'
gem 'pg'
gem 'rake'
View
@@ -31,10 +31,9 @@ GEM
hike (1.2.3)
json (1.8.1)
kgio (2.8.1)
+ kramdown (1.2.0)
launchy (2.1.2)
addressable (~> 2.3)
- maruku (0.6.1)
- syntax (>= 1.0.0)
method_source (0.8.2)
mime-types (2.0)
mini_portile (0.5.2)
@@ -106,8 +105,8 @@ DEPENDENCIES
capybara-webkit
foreman
haml
+ kramdown
launchy
- maruku (~> 0.6.1)
newrelic_rpm
pg
pry-debugger
View
@@ -11,6 +11,10 @@ few changes:
- Updated gems
- Added sprockets
- Added [foundation](http://foundation.zurb.com/)
+- Uses [kramdown](https://github.com/gettalong/kramdown) instead of
+[maruku](https://github.com/bhollis/maruku/). It is faster and has
+better support for embedded html
+- Uses [puma](https://github.com/puma/puma)
Made some changes to the default code base in
order to remove empty spaces, fix test suite, upgrade used gems and
@@ -26,8 +30,8 @@ customize its configuration.
## Just for fun roadmap:
-- Be able to post/fix older posts
-- Syntaxis highlight for different languages
+- Be able to post on any date
- Post review history
- Responsive layouts
+- Full JS app consuming API
- Try to improve code so that codeclimate becomes happier [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/chischaschos/scanty)
View
@@ -1,6 +1,3 @@
-require 'maruku'
-require 'syntax/convertors/html'
-
Sinatra::Blogging::App.settings.db.create_table? :posts do
primary_key :id
String :title
@@ -49,43 +46,7 @@ def self.make_slug(title)
title.downcase.gsub(/ /, '_').gsub(/[^a-z0-9_]/, '').squeeze('_')
end
- ########
-
def to_html(markdown)
- out = []
- noncode = []
- code_block = nil
- markdown.split("\n").each do |line|
- if !code_block and line.strip.downcase == '<code>'
- out << Maruku.new(noncode.join("\n")).to_html
- noncode = []
- code_block = []
- elsif code_block and line.strip.downcase == '</code>'
- convertor = Syntax::Convertors::HTML.for_syntax "ruby"
- highlighted = convertor.convert(code_block.join("\n"))
- out << "<code>#{highlighted}</code>"
- code_block = nil
- elsif code_block
- code_block << line
- else
- noncode << line
- end
- end
- out << Maruku.new(noncode.join("\n")).to_html
- out.join("\n")
- end
-
- def split_content(string)
- parts = string.gsub(/\r/, '').split("\n\n")
- show = []
- hide = []
- parts.each do |part|
- if show.join.length < 100
- show << part
- else
- hide << part
- end
- end
- [ to_html(show.join("\n\n")), hide.size > 0 ]
+ Kramdown::Document.new(markdown).to_html
end
end
View
@@ -20,11 +20,14 @@
it "produces html from the markdown body" do
@post.body = "* Bullet"
- @post.body_html.should == "<ul>\n<li>Bullet</li>\n</ul>"
+ @post.body_html.should == "<ul>\n <li>Bullet</li>\n</ul>\n"
end
- it "syntax highlights code blocks" do
- @post.to_html("<code>\none\ntwo\n</code>").should == "\n<code><pre><span class=\"ident\">one</span>\n<span class=\"ident\">two</span></pre></code>\n"
+ it "syntax highlights ruby blocks" do
+highlighted_code = <<DOC
+<div><div class=\"CodeRay\">\n <div class=\"code\"><pre><span class=\"line-numbers\"><a href=\"#n1\" name=\"n1\">1</a></span>puts <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">hi</span><span style=\"color:#710\">&quot;</span></span>\n</pre></div>\n</div>\n</div>
+DOC
+ @post.to_html("~~~ruby\nputs \"hi\"\n~~~").should eq highlighted_code
end
it "makes the tags into links to the tag search" do

0 comments on commit 7b73b7d

Please sign in to comment.