Skip to content

Instantly share code, notes, and snippets.

@al6x
Created October 18, 2012 21:52
Show Gist options
  • Save al6x/3914983 to your computer and use it in GitHub Desktop.
Save al6x/3914983 to your computer and use it in GitHub Desktop.
Redcarpet as RESTful service
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