Skip to content

Instantly share code, notes, and snippets.

@bjeanes
Created July 11, 2009 12:58
Show Gist options
  • Select an option

  • Save bjeanes/145239 to your computer and use it in GitHub Desktop.

Select an option

Save bjeanes/145239 to your computer and use it in GitHub Desktop.
code = Uv.parse(code, "xhtml", "ruby", false, "sunburst")
# semantics (add <code> tag)
code = code.gsub(/^<pre class="([a-zA-Z_-]+)">/,%Q[<pre><code lang="\1">])
code = code.gsub(/<\/pre>$/,'</code></pre>')
# Add line numbers using a table (so they aren't included in selections!
lines = code.split(/\n/).size
%Q[<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td valign="top" align="right"><pre>#{(1...lines).to_a.join("\n")}</pre></td>
<td valign="top">#{code}</td>
</tr>
</tbody>
</table>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment