After some searching, I found the solution which I liked very much. Its vim's "TOhtml" feature. I liked this feature because I use vim for code writing. So, I do not have to go to any other tool. Next, it converts the code into html format which I can embed in any webpage which is great.
But, the default html from vim's TOhtml did not look very clean. It seems that the color I see in my terminal and the color I see in browser are quite different. I found this article which gives an guideline on how can we change the html output by doing some simple vim scripting. I almost followed his way completely, except that he used a different color scheme plugin for vim where I decided to change the style sheet for changing the look. Here's one example of ruby code outputed using the vim's TOhtml feature.
$VERBOSE = nil
require 'gnuplot'
outfile = "test.obj"
plot = Plot.new
x = (0..50).to_a
y = x.collect { |v| v**2 }
data = DataSet.new([x,y])
plot.data << data
plot.term "tgif"
plot.output outfile
plot.plot
require 'gnuplot'
outfile = "test.obj"
plot = Plot.new
x = (0..50).to_a
y = x.collect { |v| v**2 }
data = DataSet.new([x,y])
plot.data << data
plot.term "tgif"
plot.output outfile
plot.plot
Isn't it clean enough? I like it. It's easy to do. Run command in vim, copy the code and then paste in the Blogger. I am hoping to post articles on programming languages from now on and this method will give me a good boost.
No comments:
Post a Comment