I am trying to add Markdown to my Rails 3 web app but am having problems.
I have tried rdiscount and markdownizer but either they’re not working or I’m not writing the correct code for them.
The code I have at the moment to display a text field is <%=h simple_format (@user.desktopinfo) %>
I want to increase the functionality of this text by adding Markdown but I am unable to get it work, please help! 🙂
EDIT 2
Using markdownizer broke my app, so I am now using BlueCloth. Add bluecloth to the gem file and add this <%= raw BlueCloth.new(@user.desktopinfo).to_html %>
🙂
EDIT
Actually, just trying again…
With markdownizer, with markdownize! :desktopinfo in the user model and <%= @user.rendered_desktopinfo %> on the page that shows the text, I get this: <h1>this is a h1</h1> on the text when I enter
this is a h1
============
so I am halfway there! How do I now turn this code into html?
You haven’t really specified exactly what you are after, but I use bluecloth when working with markdown. You can add ‘bluecloth’ to your Gemfile.
To parse your markdown it is as simple as:
You need the keyword raw. so the HTML is not escaped.