bjeanes (owner)

Revisions

gist: 145239 Download_button fork
public
Public Clone URL: git://gist.github.com/145239.git
Embed All Files: show embed
ultraviolet_table_based_numbers.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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>]