Under root:
1, install github markdown gem
gem install github-markdown
2, Add markdown gem into Gem file
root@ubuntuChef:/opt/ruby/user# vim Gemfile
gem 'github-markdown'
3, may need do:
bundle install
4, Define your markdown in your controller
I put MD file under app/assets/markdown folder
ang@ubuntuChef:/opt/ruby/user$ vim app/controllers/myusers_controller.rb
def markdown
#@myusers = Myuser.all
require 'github/markdown'
#require 'rdiscount'
mdfile = File.join(Rails.root, 'app', 'assets', 'markdown', 'test.md')
mymd = File.open(mdfile, 'rb') { |file| file.read }
@md = GitHub::Markdown.render(mymd)
#@md = RDiscount.new(mymd, :smart, :filter_html).to_html
end
5, update the view - DON'T forget RAW
root@ubuntuChef:/opt/ruby/user# vim app/views/myusers/markdown.html.erb
<h1>Markdown</h1>
<%= raw(@md) %>
Subscribe to:
Post Comments (Atom)
-
Step 1, New a project rails new demo Step 2, Update Gemfile add paperclip, mysql2 gem, enable JavaScript runtime gem 'mysql2' ...
-
When trying to access transmission from web-browswer i got the message : 403: Forbidden Unauthorized IP Address. Either disable the IP ad...
-
I used 7z to zip this file under Windows, try to unzip it under linux [ang@walker temp]$ gunzip 2011.sdf.zip gunzip: 2011.sdf.zip: unkno...
No comments:
Post a Comment