HTML formated Ruby code

  • Thread starter Felipe Contreras
  • Start date
F

Felipe Contreras

Hi,

Does anyone knows how all that beautiful HTML formated Ruby code on
ruby-lang.org is generated?

Like this:

<div id="code">

<div class="comment"># Output "I love Ruby"</div>
<div>say <span class="op">=</span> <span class="string">"I love
Ruby"</span></div>
<div>puts say</div>
<div class="blank-line">&nbsp;</div>
<div class="comment"># Output "I *LOVE* RUBY"</div>

<div>say<span class="op">[</span><span
class="string">'love'</span><span class="op">]</span> = <span
class="string">"*love*"</span></div>
<div>puts say<span class="op">.</span>upcase</div>
<div class="blank-line">&nbsp;</div>
<div class="comment"># Output "I *love* Ruby"</div>

<div class="comment"># five times</div>
<div><span class="numeric">5</span><span class="op">.</span>times
<span class="op">{</span> puts say <span class="op">}</span></div>

</div>
 
A

akbarhome

Hi,

Does anyone knows how all that beautiful HTML formated Ruby code on
ruby-lang.org is generated?

Like this:

<div id="code">

<div class="comment"># Output "I love Ruby"</div>
<div>say <span class="op">=</span> <span class="string">"I love
Ruby"</span></div>
<div>puts say</div>
<div class="blank-line">&nbsp;</div>
<div class="comment"># Output "I *LOVE* RUBY"</div>

<div>say<span class="op">[</span><span
class="string">'love'</span><span class="op">]</span> = <span
class="string">"*love*"</span></div>
<div>puts say<span class="op">.</span>upcase</div>
<div class="blank-line">&nbsp;</div>
<div class="comment"># Output "I *love* Ruby"</div>

<div class="comment"># five times</div>
<div><span class="numeric">5</span><span class="op">.</span>times
<span class="op">{</span> puts say <span class="op">}</span></div>

</div>

My guess is they make it manually. If not, it is a part of RadiantCMS
project that they use it.
 
J

James Edward Gray II

Does anyone knows how all that beautiful HTML formated Ruby code on
ruby-lang.org is generated?

I've hand edited most of the code on that site for various reasons,
but TextMate can be used to generate HTML pretty close to it. The
site's syntax coloring has been made into a TextMate theme called
Ruby Blue:

http://wiseheartdesign.com/2006/03/11/ruby-blue-textmate-theme

When you have code open with that theme on, you can use commands in
the TextMate bundle to convert it to HTML.

James Edward Gray II
 
D

Daniel Leidisch

Felipe Contreras said:
Hi,

Does anyone knows how all that beautiful HTML formated Ruby code on
ruby-lang.org is generated?

I don't know how they did it, but you can run

:so $VIMRUNTIME/syntax/2html.vim

from inside vim and have all the available color themes output as
HTML. In Emacs I use htmlize.el. Another option would be highlight,
which is run from the command line.
 
F

Felipe Contreras

I've hand edited most of the code on that site for various reasons,
but TextMate can be used to generate HTML pretty close to it. The
site's syntax coloring has been made into a TextMate theme called
Ruby Blue:

http://wiseheartdesign.com/2006/03/11/ruby-blue-textmate-theme

When you have code open with that theme on, you can use commands in
the TextMate bundle to convert it to HTML.

Thanks!

Unfortunately I don't have TextMate since I'm on Linux.

I really really like VIM, but I'm starting to feel it has a lot of shortcomings.

Hmm, maybe some Ruby extensions inside VIM is just what I need...

/me drools
 
C

come

Hi,

For my HTML output, I use the ScreenShot plugin with vim. It comes
with the "TOhtml" command which produce an HTML output on my windows
computer. It should works on Linux, too.

The output looks like this :
<pre>
search_engines =
<font color="#6a5acd">%w[</font><font color="#ff00ff">Google Yahoo
MSN</font><font color="#6a5acd">]</font>.map <font
color="#804040"><b>do</b></font> |<font color="#008080">engine</font>|
<font color="#6a5acd">&quot;</font><font color="#ff00ff"><a
href="http://www.">http://www.</a></font><font color="#6a5acd">&quot;</
font> + engine.downcase + <font color="#6a5acd">&quot;</font><font
color="#ff00ff">.com</font><font color="#6a5acd">&quot;</font>
<font color="#804040"><b>end</b></font>
</pre>

For my output on doc Word, It is possible to insert HTML output, but
SciTE has a "Copy to RTF" command which is a litte faster.

Come
 
P

Phrogz

You could also try CodeRayhttp://coderay.rubychan.de/

I've been wanting to write a Lua scanner for CodeRay, but haven't been
able (in mere minutes of exploration) to figure out where to begin.
Has anyone worked with CodeRay as a language author, and could provide
some tips/webpages/articles/documentation on how to write a plugin for
a new language for it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top