I have a project which can render markdown files, through redcarpet.
Middleman is version 3.3.3
The page of concern uses erb.
The project pulls some Markdown from a json file like so:
<div>
<% data.songs.songs.each do |f| %>
<% if f.title == "All The Heavens" %>
<%= f.notes.split("\n").join("</br>") %>
<% end %>
<% end %>
</div>
Unfortunately, that just displays the markdown in plain text.
The solution appears to be a Markdown view helper, something like:
module FormatHelpers
def markdown(source)
Tilt::RedcarpetTemplate.new { source }.render
end
end
And make sure the page is named something like reader.html.md.erb
Then do something like:
<div>
<% data.songs.songs.each do |f| %>
<% if f.title == "All The Heavens" %>
<% markdown do %>
<%= f.notes.split("\n").join("</br>") %>
<% end %>
<% end %>
<% end %>
</div>
Thus far… Nothing has worked for me.
Hoping somebody has some ideas on this?