So I’ve been building my paste app on my local machine, and I’ve come across a small problem that has been bugging me. I need to figure out how to do syntax highlighting. In PHP, I could pass the user choice:
<select name="paste_syntax">
<option value="ruby">Ruby</option>
<option value="c">C</option>
<option value="html-xml">HTML/XML</option>
<option value="php">PHP</option>
</select>
and use $_POST to pass the variable chosen here, to highlight the syntax. E.g:
<pre class='mypostvar'>some code</pre>
However, in Rails, I’m not sure how to do this. I was thinking of creating a paste column in the paste table, which is linked to a paste_syntax table, containing all the paste syntax options. The 2 are linked. My question is, should I do this, or is there another way?
Help is appreciated!
~Adil
I’d use syntax highlighter and then I wouldn’t bother rails for this, but you can change the highlighting by changing class to your code, with some jQuery for example: