Created
July 11, 2009 12:58
-
-
Save bjeanes/145239 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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