librelist archives

« back to archive

Redcarpet support

Redcarpet support

From:
Misha Reyzlin
Date:
2011-12-18 @ 17:43
Hi,
I have the following code in my app.rb:
# Add Redcarpet support
module Nesta
  class FileModel
    def to_html ( scope = nil )
      html = convert_to_html @format, scope, markup
      Typogruby.improve html
    end

    def convert_to_html ( format, scope, text )
      @markdown = Redcarpet::Markdown.new(
                    Redcarpet::Render::HTML,
                    :no_intra_emphasis => true,
                    :lax_html_blocks => true,
                    :autolink => true,
                    :space_after_headers => true
                  )

      case format
        when :mdown
          @markdown.render( text )
          # Maruku.new( text ).to_html
        when :haml
          Haml::Engine.new( text ).to_html(scope || Object.new)
        when :textile
          RedCloth.new( text ).to_html
        end
    end
  end
end

But when I run the server and request the page whose contents are stored in
a .mdown format, I can see following warnings in the console:
 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| Could not find ref_id = "method" for md_link(["method"],"method")
| Available refs are []
+---------------------------------------------------------------------------
! ……… some code here
\___________________________________________________________________________
Not creating a link for ref_id = "method".

How can I make Nesta parse markdown files with Redcarpet? How can I see
what parser is being used at compilation time?

Thanks!

Re: [nesta] Redcarpet support

From:
Graham Ashton
Date:
2011-12-18 @ 18:24
On 18 Dec 2011, at 17:43, Misha Reyzlin <mrejzlin@gmail.com> wrote:

> How can I make Nesta parse markdown files with Redcarpet?

Have a look at this:

http://nestacms.com/docs/creating-content/changing-the-markdown-processor

Re: [nesta] Redcarpet support

From:
Misha Reyzlin
Date:
2011-12-18 @ 19:24
Hello Graham, thanks for this link, my code has got old with the recent
updates then.
I am now able to see the content and there are no warnings from Maruku.
Is there some way to see what is actually being used in console though?

I was also using typogruby library in order to enhance typography of the
content.

I am now trying this in app.rb and I get errors:
module Nesta
  class FileModel
    def to_html ( scope = nil )
      html = convert_to_html ( @format, scope, markup )
      Typogruby.improve html
    end
  end
end

Here's what I get in the browser:
Boot Error

Something went wrong while loading config.ru
SyntaxError: /Users/m/rubycode/mishareyzlin.com/themes/mr/app.rb:7: syntax
error, unexpected ',', expecting ')' html = convert_to_html ( @format,
scope, markup ) ^ /Users/m/rubycode/mishareyzlin.com/themes/mr/app.rb:7:
syntax error, unexpected ')', expecting '=' /Users/m/rubycode/
mishareyzlin.com/themes/mr/app.rb:171: syntax error, unexpected
keyword_do_block, expecting keyword_end pages.select do |page| ^
/Users/m/rubycode/mishareyzlin.com/themes/mr/app.rb:172: syntax error,
unexpected tSTRING_BEG, expecting keyword_end page.path.include? "notes/" ^
/Users/m/rubycode/mishareyzlin.com/themes/mr/app.rb:228: syntax error,
unexpected keyword_end, expecting $end

Thanks!

On Sun, Dec 18, 2011 at 7:24 PM, Graham Ashton <graham@effectif.com> wrote:

> On 18 Dec 2011, at 17:43, Misha Reyzlin <mrejzlin@gmail.com> wrote:
>
> > How can I make Nesta parse markdown files with Redcarpet?
>
> Have a look at this:
>
> http://nestacms.com/docs/creating-content/changing-the-markdown-processor
>

Re: [nesta] Redcarpet support

From:
Graham Ashton
Date:
2011-12-18 @ 19:29
On 18 Dec 2011, at 19:24, Misha Reyzlin wrote:

> Here's what I get in the browser:
> Boot Error
> 
> Something went wrong while loading config.ru
> SyntaxError: /Users/m/rubycode/mishareyzlin.com/themes/mr/app.rb:7: 
syntax error, unexpected ',', expecting ')' html = convert_to_html ( 
@format, scope, markup )

Your syntax error is caused by too much whitespace. Remove the space 
between "convert_to_html" and "(" and it your method should compile.

To see which processor Tilt is using you'll have to investigate Tilt a 
bit. I suspect there will be a way to get it to report which engine it's 
using (though if you've added RedCarpet to your Gemfile, it'll be using 
RedCarpet).

I'm short on time so can't check myself, but here are the docs:

https://github.com/rtomayko/tilt

Cheers,
Graham