Markdown Preview using ruby and sinatra simple script

Posted on

every time i write markdown in my readme file i have to write something wrong, so i wrote this script to solve my problem

#!/usr/bin/env ruby
# gem install sinatra --no-document
# gem install github-markdown --no-document
require 'sinatra'
require 'github/markdown' 
set :port, 3000

get '/' do
    <!DOCTYPE html>
        <meta charset="utf-8">
        <title>Markdown tester</title>
        <textarea id="markdown" style="width:100%;height:300px;"></textarea>
        <div id="preview" ></div>
        <script src=""></script>
        <script type="text/javascript">
            $.post('/preview', {md:$('#markdown').val()}, function(response){

post '/preview' do
    GitHub::Markdown.render_gfm params['md']

Leave a Reply

Your email address will not be published. Required fields are marked *