Tilt (Kramdown) Preventing Erb Processing When Rendering Markdown

Tilt (kramdown) preventing ERB processing when rendering markdown

Since you already have HAML parsing correctly, and when you render verbatim links it works, try using a helper to directly inject the links without needing to go to ERB. Since HAML will already run Ruby code, I see no need to pass it through ERB too. I think eval will allow you to get the same effect you're using ERB for. Something like this:

def refonly(text)
text.scan(/ref\.(page[A-Z])/).each do |groups|
page_name = groups[0]
text.gsub!(/ref\.#{page_name}/, eval("data.pages.#{page_name}.link"))
end
text
end

EDIT: Scanning the text will allow you to get each page_name so you can loop through each one and replace each page reference with its link.

object in rails erb file not rendering properly

Because you have <%= student.each (instead of just <% student.each) and so the value of the each is also being rendered (which is the full list you pass in).

Middleman Kramdown Converter for a html tags

Middleman overrides convert_a (and convert_img) in middleman-core/lib/middleman-core/renderers/kramdown.rb by deriving from Kramdown::Converter::Html and without calling super.

Therefore by prepending to Kramdown::Converter::Html, your method is replaced by middleman's version.

You might be more successful by monkeypatching Middleman::Renderes::MiddlemanKramdownHTML instead, but you'll need to be careful not to violate middleman's expectations of the convert_a method.

Custom helper with block

Apparently, when using blocks, the equal sign has to be dropped. The following works:

<% wrap_me('span') do %>
Hello
<% end %>

Rendering sections of ERb templates in Markdown with Middleman

You defined your markdown method to receive one parameter called text. But what you provide in your views is a block.

To make things work, you either change the way you call the markdown helper method in the view

<%= markdown 'this is some markdown text in here' %>

or you change the markdown helper to accept a block

def markdown
Redcarpet.new(yield).to_html
end

P.S.: The Redcarpet syntax has changed a bit since the Railscast, so if you are using a more recent gem version, implementing it this way won't work.

Starting at least from 3.3.4, perhaps earlier, you have to create a specific renderer and then call render on it with the markdown as an argument, i.e.

def markdown
Redcarpet::Render::XHTML.new.render(yield)
end

Up to date documentation can be found here: https://github.com/vmg/redcarpet

Strikethrough Text in a Merea-Frameowrk Site?

After updating Jekyll and Kramdown to their latest releases, strikethrough works. Here's an example Morea site illustrating strikethrough:

http://morea-framework.github.io/morea-news-page-example/

The home.md page source is here:

https://raw.githubusercontent.com/morea-framework/morea-news-page-example/master/src/morea/morea/home.md

To make this work correctly I updated gem, jekyll, and kramdown:

% sudo gem update --system
Password:
Updating rubygems-update
Fetching: rubygems-update-2.6.4.gem (100%)
Successfully installed rubygems-update-2.6.4
Parsing documentation for rubygems-update-2.6.4
Installing ri documentation for rubygems-update-2.6.4
Installing darkfish documentation for rubygems-update-2.6.4
Parsing documentation for rubygems-update-2.6.4
Installing RubyGems 2.6.4
RubyGems 2.6.4 installed
Parsing documentation for rubygems-2.6.4
Installing ri documentation for rubygems-2.6.4

% sudo gem update jekyll
Updating installed gems
Updating jekyll
Fetching: jekyll-3.1.6.gem (100%)
Successfully installed jekyll-3.1.6
Parsing documentation for jekyll-3.1.6
Installing ri documentation for jekyll-3.1.6
Installing darkfish documentation for jekyll-3.1.6
Parsing documentation for jekyll-3.1.6
Gems updated: jekyll

% sudo gem update kramdown
Updating installed gems
Updating kramdown
Fetching: kramdown-1.11.1.gem (100%)
Successfully installed kramdown-1.11.1
Parsing documentation for kramdown-1.11.1
Installing ri documentation for kramdown-1.11.1
Installing darkfish documentation for kramdown-1.11.1
Parsing documentation for kramdown-1.11.1
Gems updated: kramdown

Maybe you only need to update kramdown, but this seemed like a good opportunity to update Jekyll as well.



Related Topics



Leave a reply



Submit