On Sat, Dec 09, 2006 at 06:09:23AM +0100, ryan wrote:>
> I''m wanting to use the Syntax library, but I don''t know
how to make use
> of it. Let''s say I had the following:
>
> <pre>
> # comments go here
> def ruby_method
> words = Word.find_all
> end
> </pre>
>
> I''d like this to be formatted where I can apply styles to the
comments,
> and the def and so on.
>
> Can someone help me out with this? Not to be rude, but I''ve
checked out
> the syntax site, and I''m not sure I know what to do from there, so
could
> someone post a code snippet example of how to use it? Thanks in
> advance.
This is taken from the manual and modified a bit (convertor needed an s
in the end):
require ''rubygems''
# Step 1: require the HTML convertor
require ''syntax/convertors/html''
# Step 2: get an instance of the HTML convertor for the Ruby syntax
convertor = Syntax::Convertors::HTML.for_syntax "ruby"
# Step 3: convert the text to HTML
puts convertor.convert( File.read( "hilight.rb" ) )
It will output the contents of hilight.rb as syntax highlighted HTML to
the console. Is this enough?
--
Cheers,
- Jacob Atzen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---