Created
October 18, 2012 21:52
-
-
Save al6x/3914983 to your computer and use it in GitHub Desktop.
Redcarpet as RESTful service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'redcarpet' | |
render = Redcarpet::Render::HTML.new \ | |
filter_html: true, | |
safe_links_only: true | |
markdown = Redcarpet::Markdown.new render, | |
autolink: true, | |
space_after_headers: true, | |
tables: true, | |
fenced_code_blocks: true, | |
autolink: true, | |
strikethrough: true, | |
lax_spacing: true, | |
space_after_headers: true, | |
superscript: true | |
get('/markdown'){'Use POST'} | |
post '/markdown' do | |
data = request.params['data'] | |
markdown.render data | |
end | |
configure do | |
set :port, 4000 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment