Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > formatting ruby code in html

Thread Tools

formatting ruby code in html

paul vudmaska
Posts: n/a
Is there a similar function in Ruby to the
highlight_file function of php...this function takes a
file and outputs it in html....


Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

Reply With Quote
Posts: n/a
On Thu, 25 Sep 2003, paul vudmaska wrote:

> Is there a similar function in Ruby to the
> highlight_file function of php...this function takes a
> file and outputs it in html....

for f in *.[rb]; do gvim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" $f; done

vim is great.

| Ara Howard
| NOAA Forecast Systems Laboratory
| Information and Technology Services
| Data Systems Group
| R/FST 325 Broadway
| Boulder, CO 80305-3328
| Email: Removed)
| Phone: 303-497-7238
| Fax: 303-497-7259
| The difference between art and science is that science is what we understand
| well enough to explain to a computer. Art is everything else.
| -- Donald Knuth, "Discover"
| ~ > /bin/sh -c 'for lang in ruby perl; do $lang -e "print \"\x3a\x2d\x29\x0a\""; done'
Reply With Quote
Josef 'Jupp' Schugt
Posts: n/a

* Ara.T.Howard; 2003-09-25, 12:57 UTC:
> for f in *.[rb]; do
> gvim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" $f;
> done

The line breaks I inserted don't break anything else but lines.

'*.[rb]' matches file names that either end in '.r' or in '.r'. I
think you want to match all files with names ending in '.rb'. This is
done as follows:

for f in *.rb

That still doesn't solve the problem at hand. The task is not to
identify files with names ending in certain characters but
identifying files with certain content. This problem can be solved in
two stages by first identifying the names of all files (in contrast
to directories and other things) and then finding out which of these
files are ruby programs:

for f in $(file $(find . -type f)|grep -i ruby|cut -d : -f1); do

"$(...)" is the POSIX equivalent of "`...`" that has a major
advantage over the latter form: It can easily be nested.

There is good reason to insist on *not* mixing up file extensions
with file types. Under Unix and Linux programs may not have any file
extension while still being written in Ruby.

Also note that by

+"colorscheme <name-of-color-scheme>"
+"syntax on"

you can use a different color scheme for syntax highlighting than

Please take notice of signature! / Bitte Signature beachten!

Josef 'Jupp' Schugt
*Warning!* For sending me messages > 100 kB you need my explicit
permission. Otherwise they will be silently discarded.
*Vorsicht!* Mails > 100 KB nehme ich nur nach vorheriger Absprache
entgegen. Ohne eine solche Absprache werden sie ungelesen geloescht.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
Html code cleaner - Powerful HTML Code Compression Tool heren ASP .Net 1 09-14-2005 12:39 PM
HTML code warnings in html code view Craig Kenisston ASP .Net 3 10-07-2004 04:05 PM
the development environment is overzealously formatting my html when switching from design to code view Jacob Crossley ASP .Net 6 06-09-2004 08:47 PM
Need formatting options menu for formatting hard drive Mark T. Computer Support 3 11-24-2003 11:50 PM