Created
March 9, 2014 11:35
-
-
Save emad-elsaid/9446456 to your computer and use it in GitHub Desktop.
Everytime i write markdown and commit i find error, so i solved the problem ;)
This file contains hidden or 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
#!/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 | |
<<-EOT | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Markdown tester</title> | |
</head> | |
<body> | |
<textarea id="markdown" style="width:100%;height:300px;"></textarea> | |
<div id="preview" ></div> | |
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
<script type="text/javascript"> | |
$('#markdown').keyup(function(){ | |
$.post('/preview', {md:$('#markdown').val()}, function(response){ | |
$('#preview').html(response); | |
}); | |
}); | |
</script> | |
</body> | |
</html> | |
EOT | |
end | |
post '/preview' do | |
GitHub::Markdown.render_gfm params['md'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment