Add syntax highlighting to proxy generated pages

I have a number of pages that are generates via proxy. The data for the pages lives in a sub-directory in the data/ directory, and the proxy call is like so:

data.projects.each do |slug, project|
  proxy "/projects/#{slug}.html", "templates/project.html", :locals => { :project => project }, :ignore => true
end

As an example of what one of those pages would look like:

title: Metadata
image: projects/metadata.png
github: https://github.com/smargh/metadata
tags:
  - python
description: A Python module for searching your local files using metadata queries.
readme: |
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tristique ut quam non fermentum. In a sodales mi.
  Ut non ullamcorper ante, sit amet sagittis diam. Ut turpis orci, malesuada a lacus eu, fringilla faucibus felis.
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam nec est at nibh mattis mattis eget sit amet leo.
  Cras tristique vestibulum nisi. Fusce iaculis venenatis metus, vitae luctus nunc blandit eget.
  Integer et nunc sed augue varius varius eu et elit. Suspendisse eu nisl venenatis, vehicula mi eu, rhoncus mauris.
  Integer magna diam, sodales a volutpat vel, cursus posuere nisi.

When generating the page, I use a simple helper method to convert the Markdown text in readme into HTML:

helpers do
  def markdownify(content)
    Tilt['markdown'].new { content }.render
  end
end

Thus, in the project.html.erb file, I have this line at one point:

<div id="description"><%= markdownify project['readme'] %></div>

This works well enough, but my syntax highlighting isn’t used when generating these pages (as opposed to “normally” generated pages, where it works perfectly). My assumption is that the data pipeline for proxy-generated pages is such that the :syntax code is never called.

My question is how to have my text run through the syntax highlighter, such that the resulting HTML is properly rendered? Do I need to add another helper method? If so, do I run it before the Markdown is converted or after? Can I achieve this more simply? Any help would be greatly appreciated.

stephen

1 Like

@smargh Did you ever find a solution for this? I’m hitting the same problem.

Hello, i have the same question, using proxy from http://advanced.name. Did you find the solution?