Created
September 14, 2010 18:50
-
-
Save mudge/579549 to your computer and use it in GitHub Desktop.
JRuby class for using pegdown as the Rails Markdown processor.
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
| require 'markdown' | |
| module ApplicationHelper | |
| def markdown(text) | |
| if text.present? | |
| Markdown.new(text).to_html | |
| else | |
| text | |
| end | |
| end | |
| end |
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
| require 'parboiled4j-0.9.8.2' | |
| require 'pegdown-0.8.5.3' | |
| class Markdown | |
| def initialize(text) | |
| @text = text | |
| @processor = Java::OrgPegdown::PegDownProcessor.new(Java::OrgPegdown::Extensions::AUTOLINKS | Java::OrgPegdown::Extensions::HARDWRAPS) | |
| end | |
| def to_html | |
| @processor.markdownToHtml(@text) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment