Markdown filter not working on server

18 views
Skip to first unread message

apremdas

unread,
Aug 25, 2008, 7:55:45 PM8/25/08
to Haml
Hi there,

In my app I load some markdown text from environment.rb and display it
via haml using the markdown filter

This is my markdown text kept in a hash in environment.rb

REGISTRY[:postage_explanation] = <<EOF
Why is postage so much?
========================
...
EOF

This is my partial

#postageExplanation
:markdown
#{REGISTRY[:postage_explanation]}

This works fine on dev machines running OSX Leopard in development and
production, but the markdown is not processed on my Ubuntu server. My
Ubuntu server has the relevant gems installed I think

*** LOCAL GEMS *** - full list at end of post
...
haml (2.0.1, 2.0.0)
...
RedCloth (4.0.1, 3.0.4)

Any ideas why this might be happening or how to investigate further
would be most appreciated

Many thanks

Andrew

p.s. Using Rails 2.1




*** LOCAL GEMS *** - full list

actionmailer (2.1.0, 2.0.2, 1.3.3, 1.3.2, 1.2.5)
actionpack (2.1.0, 2.0.2, 1.13.3, 1.13.2, 1.12.5)
actionwebservice (1.2.6, 1.2.3, 1.2.2, 1.1.6)
activerecord (2.1.0, 2.0.2, 1.15.3, 1.15.2, 1.14.4)
activeresource (2.1.0, 2.0.2)
activesupport (2.1.0, 2.0.2, 1.4.2, 1.4.1, 1.3.1)
builder (2.1.2, 2.1.1)
capistrano (2.4.3, 2.1.0, 1.4.1)
cgi_multipart_eof_fix (2.5.0, 2.1)
columnize (0.1)
daemons (1.0.10, 1.0.9, 1.0.5)
fastthread (1.0.1, 1.0)
flexmock (0.8.2, 0.8.0)
gem_plugin (0.2.3, 0.2.2)
haml (2.0.1, 2.0.0)
highline (1.4.0)
hoe (1.7.0, 1.5.3)
image_science (1.1.3)
linecache (0.43)
markaby (0.5)
metaid (1.0)
mongrel (1.1.5, 1.1.3, 1.0.1)
mongrel_cluster (1.0.5, 0.2.1)
mysql (2.7)
needle (1.3.0)
net-scp (1.0.1)
net-sftp (2.0.1, 1.1.0)
net-ssh (2.0.3, 1.1.2, 1.0.10)
net-ssh-gateway (1.0.0)
passenger (2.0.1, 1.0.5)
rack (0.3.0)
rails (2.1.0, 2.0.2, 1.2.3)
rails-app-installer (0.2.0)
rake (0.8.1, 0.7.2)
rcov (0.8.1.2.0)
RedCloth (4.0.1, 3.0.4)
rspec (1.1.4, 1.1.2, 1.1.1)
ruby-debug (0.10.1, 0.10.0)
ruby-debug-base (0.10.1, 0.10.0)
rubyforge (1.0.0)
rubygems-update (1.2.0, 1.0.1, 0.9.5)
RubyInline (3.7.0, 3.6.7)
sources (0.0.1)
sqlite3-ruby (1.2.2, 1.2.1)
typo (5.0.3.98.1, 5.0.2, 5.0.1)
xmpp4r (0.3.2)


Chris McGrath

unread,
Aug 26, 2008, 4:27:09 PM8/26/08
to ha...@googlegroups.com

On 26 Aug 2008, at 00:55, apremdas wrote:

>
>
> This works fine on dev machines running OSX Leopard in development and
> production, but the markdown is not processed on my Ubuntu server. My
> Ubuntu server has the relevant gems installed I think
>
> *** LOCAL GEMS *** - full list at end of post
> ...
> haml (2.0.1, 2.0.0)
> ...
> RedCloth (4.0.1, 3.0.4)
>
> Any ideas why this might be happening or how to investigate further
> would be most appreciated

RedCloth 4.0.1 removed support for Markdown, it's Textile only.

Cheers,

Chris

Chris McGrath

unread,
Aug 26, 2008, 4:59:17 PM8/26/08
to ha...@googlegroups.com

Well, not specifically 4.0.1, support was removed in 4.0

> Cheers,
>
> Chris
>
> >

Nathan Weizenbaum

unread,
Aug 26, 2008, 5:24:52 PM8/26/08
to ha...@googlegroups.com
I suppose I should teach Haml about this...

Geffy

unread,
Aug 27, 2008, 5:12:55 AM8/27/08
to Haml
For Markdown processing the primary gem is the old, unmaintained,
buggy BlueCloth. There's also now rdiscount and rpeg-markdown
alternatives to BlueCloth. Both are more correct parsers and faster I
believe.

Read http://tomayko.com/writings/ruby-markdown-libraries-real-cheap-for-you-two-for-price-of-one
for details.

To use them, I've not tried this yet, but I think you have to have the
following in your config/environment.rb, in this case for RDiscount

begin
require 'rdiscount'
BlueCloth = RDiscount
rescue LoadError
require 'bluecloth'
end

apremdas

unread,
Aug 27, 2008, 9:11:36 AM8/27/08
to Haml
Thanks for info. This explains alot, on one dev box I have 3.0.4 on
which things work fine, on another and the server I have 3.0.4 and
4.0.1 and it fails.

All best

Andrew

apremdas

unread,
Aug 27, 2008, 9:27:01 AM8/27/08
to Haml
Many thanks for this, trying out rdiscount now. Link you sent takes me
to a blank page at the moment. Following is link to rdiscount on
github.

http://github.com/rtomayko/rdiscount/tree/master

Andrew

On Aug 27, 10:12 am, Geffy <ggars...@gmail.com> wrote:
> For Markdown processing the primary gem is the old, unmaintained,
> buggy BlueCloth. There's also now rdiscount and rpeg-markdown
> alternatives to BlueCloth. Both are more correct parsers and faster I
> believe.
>
> Readhttp://tomayko.com/writings/ruby-markdown-libraries-real-cheap-for-yo...

apremdas

unread,
Aug 27, 2008, 10:46:13 AM8/27/08
to Haml
Following on from the posts by Geffy I patched my local version of
HAML additionally support RDiscount. I've included the patch below (as
outputted by git format-patch) Hope this is useful (bit of a newb at
patching apologies in advance if I messed up)


Subject: [PATCH] haml patch to use rdiscount

---
vendor/plugins/haml/lib/haml/filters.rb | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/vendor/plugins/haml/lib/haml/filters.rb b/vendor/plugins/
haml/lib/haml/filters.rb
index cb82a71..a14e076 100644
--- a/vendor/plugins/haml/lib/haml/filters.rb
+++ b/vendor/plugins/haml/lib/haml/filters.rb
@@ -245,10 +245,12 @@ END
# Uses BlueCloth or RedCloth to provide only Markdown (not
Textile) parsing
module Markdown
include Base
- lazy_require 'bluecloth', 'redcloth'
+ lazy_require 'rdiscount', 'bluecloth', 'redcloth'

def render(text)
- if @required == 'bluecloth'
+ if @required == 'rdiscount'
+ ::RDiscount.new(text).to_html
+ elsif @required == 'bluecloth'
::BlueCloth.new(text).to_html
else
::RedCloth.new(text).to_html(:markdown)

[END}

All best

Andrew

apremdas

unread,
Aug 27, 2008, 10:48:55 AM8/27/08
to Haml
Unfortunately the

begin
require 'rdiscount'
BlueCloth = RDiscount
rescue LoadError
require 'bluecloth'
end

doesn't work with HAML, because of the way HAML initialises filters.
I've included a patch in another post to address this.

All best

Andrew

On Aug 27, 10:12 am, Geffy <ggars...@gmail.com> wrote:
> For Markdown processing the primary gem is the old, unmaintained,
> buggy BlueCloth. There's also now rdiscount and rpeg-markdown
> alternatives to BlueCloth. Both are more correct parsers and faster I
> believe.
>
> Readhttp://tomayko.com/writings/ruby-markdown-libraries-real-cheap-for-yo...

Nathan Weizenbaum

unread,
Aug 27, 2008, 4:18:28 PM8/27/08
to ha...@googlegroups.com
Could you pastie this patch? Google Groups reformats patches in an odd way.

apremdas

unread,
Aug 28, 2008, 8:11:29 PM8/28/08
to Haml

Nathan Weizenbaum

unread,
Aug 30, 2008, 2:35:54 AM8/30/08
to ha...@googlegroups.com
I've pushed a revision similar to this patch, but compatible with
Mislav's RedCloth updates and including more Markdown implementations.
Thanks for the patch, though!
Reply all
Reply to author
Forward
0 new messages