For Programmers: Free Programming Magazines  


Home > Archive > Ruby > August 2005 > ruby enscript support









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ruby enscript support
Sy

2005-08-31, 9:57 pm

I got enscript working to highlight syntax with my wiki, but I've been
struggling to implement ruby support.

Has anyone had enscript working for ruby syntax?

Enscript is:
http://people.ssh.com/mtr/genscript/

I found Mike Wilson's ruby.st first referenced here:
http://www.ruby-talk.org/cgi-bin/sc...ruby-talk/10421

But I could only find it here:
http://java.thn.htu.se/%7Etoor/blog.../mixin-modules/

My notes are at:
http://jrandomhacker.info/mw/index.php/Ruby.st

Any help would be appreciated. I could just be using the wrong phrase
to summon-up ruby highlighting, or perhaps the ruby.st does not
explicitly support ruby highlighting the way I think it should..

Sy,




For more permanent reference, the original content of Mike Wilson's ruby.st=
is:

(please DO NOT quote this in your replies!)
/**
* Name: ruby
* Description: Ruby programming language.
* Author: Mike Wilson <m.v.wilson at home.com>
*/

state ruby_comment
{
/\*\\\// {
language_print ($0);
return;
}
LANGUAGE_SPECIALS {
language_print ($0);
}
}

state ruby_dquot_string
{
/\\\\./ {
language_print ($0);
}
/\"/ {
language_print ($0);
return;
}
LANGUAGE_SPECIALS {
language_print ($0);
}
}

state ruby_quot_string
{
/\\\\./ {
language_print ($0);
}
/[']/ {
language_print ($0);
return;
}
LANGUAGE_SPECIALS {
language_print ($0);
}
}

state ruby_bquot_string
{
/\\\\./ {
language_print ($0);
}
/`/ {
language_print ($0);
return;
}
LANGUAGE_SPECIALS {
language_print ($0);
}
}

state ruby
{
BEGIN {
header ();
}
END {
trailer ();
}

/* Comments. */
/#[^{].*$/ {
comment_face (true);
language_print ($0);
comment_face (false);
}

/* Ignore escaped quote marks */
/\\\"/ {
language_print ($0);
}
/\\'/ {
language_print ($0);
}
/\\\`/ {
language_print ($0);
}

/* In cgi files, JavaScript might be imbedded, so we need to look out
* for the JavaScript comments, because they might contain something
* we don't like, like a contraction (don't, won't, etc.)
* We won't put them in comment face, because they are not ruby
* comments.
*/
/\/\// {
language_print ($0);
call (eat_one_line);
}

/* String constants. */
/\"/ {
string_face (true);
language_print ($0);
call (ruby_dquot_string);
string_face (false);
}
/[']/ {
string_face (true);
language_print ($0);
call (ruby_quot_string);
string_face (false);
}

/* Backquoted command string */
/`/ {
string_face (true);
language_print ($0);
call (ruby_bquot_string);
string_face (false);
}

/* Variables globals and instance */
/[$@]\w+/ {
variable_name_face (true);
language_print ($0);
variable_name_face (false);
}

/* Variables class variable */
/@@\w+/ {
variable_name_face (true);
language_print ($0);
variable_name_face (false);
}

/([ \t]*)(def)([ \t]+)([^(]*)/ {
/* indentation */
language_print ($1);

/* def */
keyword_face (true);
language_print ($2);
keyword_face (false);

/* middle */
language_print ($3);

/* Function name. */
function_name_face (true);
language_print ($4);
function_name_face (false);
}

/\$[!@&`'+~=3D\/\\,;.<>_*$?:"]/ {
variable_name_face (true);
language_print ($0);
variable_name_face (false);
}

/* Highlighting
=09--Type face
=09private protected public

=09--Builtin face (I consider these to be somewhat special)
=09alias alias_method attr attr_accessor attr_reader attr_writer=20
=09module_alias module_function self super

=09--Reference face
=09require include

=09--Keyword face
=09and begin break case class def defined? do else elsif end=20
=09ensure eval extend false for if in method module next nil not=20
=09or redo rescue retry return then true undef unless until when
=09while yield
*/
/\\b(private|protected|public)\\b/ {
type_face (true);
language_print ($0);
type_face (false);
}

/ \\b(alias|alias_method|attr|attr_accesso
r|attr_reader|attr_writer\\
|module_alias|module_function|self|super
)\\b/ {
builtin_face (true);
language_print ($0);
builtin_face (false);
}

/\\b(include|require)\\b/ {
reference_face (true);
language_print ($0);
reference_face (false);
}

/ \\b(and|begin|break|case|class|def|defin
ed?|do|else|elsif|end|ensure|eval\=
\
|extend|false|for|if|in|method|module|ne
xt|nil|not|or|raise|redo|rescue|ret=
ry\\
|return|then|true|undef|unless|until|whe
n|while|yield)\\b/ {
keyword_face (true);
language_print ($0);
keyword_face (false);
}

LANGUAGE_SPECIALS {
language_print ($0);
}
}


/*
Local variables:
mode: c
End:
*/
(please DO NOT quote this in your replies!)


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com