lib/carte/server.rb in carte-server-0.0.13 vs lib/carte/server.rb in carte-server-0.0.14
- old
+ new
@@ -3,10 +3,11 @@
require 'mongoid'
require 'mongoid_auto_increment_id'
require 'will_paginate_mongoid'
require 'mongoid-simple-tags'
require 'mongoid/geospatial'
+require 'redcarpet'
require 'carte/server/validators'
require 'carte/server/models'
module Carte
class Server < Sinatra::Base
@@ -50,9 +51,14 @@
end
if content = params[:content]
cards = cards.any_of({content: /#{content}/i})
end
cards = cards.paginate(per_page: 9, page: params[:page])
+ end
+
+ def markdown2html(markdown)
+ renderer = Redcarpet::Render::HTML.new(filter_html:true)
+ Redcarpet::Markdown.new(renderer, autolink: true).render(markdown)
end
end
get '/' do
haml :index