Professional Web Applications Themes

Ruby syntax highlighting for Ruby - Ruby

Hi! Add the following to $HOME/.nanorc for Ruby syntax highlighting in Nano. Please report any issues - it is a quick and dirty hack. ################################################## ################### # Ruby syntax highlighting for Nano. # Author: Josef 'Jupp' Schugt, jupp(a)rubyforge.org # License: GPL 2 or later # Version: 0.1 of 2004-02-20 ################################################## ################### # Automatically use for '.rb' files syntax "ruby" ".*\.*rb$" # General color white ".+" # Operators color brightyellow "::|\*\*|!|~|\*|/|%|\+|-|&|<<|>>|\|\^|>|>=|<|<=" color brightyellow "<=>|\|\||!=|=~|!~|&&|+=|-=|=|\.\.|\.\.\." color brightyellow "\<not\>|\<and\>|\<or\>" # Keywords color brightyellow "\<(BEGIN|END|alias|and|begin|break|case)\>" color brightyellow "\<(class|def|defined|do|else|elsif|end)\>" color brightyellow "\<(ensure|for|if|in|module|next|not|or|redo)\ >" color brightyellow "\<(rescue|retry|return|self|super|then|undef) \>" color brightyellow "\<(unless|until|when|while|yield)\>" # false, nil, true color ...

  1. #1

    Default Ruby syntax highlighting for Ruby

    Hi!

    Add the following to $HOME/.nanorc for Ruby syntax highlighting in
    Nano. Please report any issues - it is a quick and dirty hack.

    ################################################## ###################
    # Ruby syntax highlighting for Nano.
    # Author: Josef 'Jupp' Schugt, jupp(a)rubyforge.org
    # License: GPL 2 or later
    # Version: 0.1 of 2004-02-20
    ################################################## ###################

    # Automatically use for '.rb' files
    syntax "ruby" ".*\.*rb$"

    # General
    color white ".+"

    # Operators
    color brightyellow "::|\*\*|!|~|\*|/|%|\+|-|&|<<|>>|\|\^|>|>=|<|<="
    color brightyellow "<=>|\|\||!=|=~|!~|&&|+=|-=|=|\.\.|\.\.\."
    color brightyellow "\<not\>|\<and\>|\<or\>"

    # Keywords
    color brightyellow "\<(BEGIN|END|alias|and|begin|break|case)\>"
    color brightyellow "\<(class|def|defined|do|else|elsif|end)\>"
    color brightyellow "\<(ensure|for|if|in|module|next|not|or|redo)\ >"
    color brightyellow "\<(rescue|retry|return|self|super|then|undef) \>"
    color brightyellow "\<(unless|until|when|while|yield)\>"

    # false, nil, true
    color magenta "\<(false|nil|true)\>"

    # Above must not match 'nil?'
    color white "\<nil\?"

    # external stuff
    color brightgreen "\<(load|require|%q|%!|%Q|%r|%x)"

    # Iterators
    color brightgreen "\|\w*\|"

    # Constants
    color yellow "\<[A-Z]\w*\>"

    # Symbols
    color yellow "([ \t]|^):(||\$)?\w+\>"

    # Strings
    color green "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'"

    # Backticks
    color green "`(\\.|[^\\\"])*`"

    # Regular expressions
    color green "/(\\.|[^\\/])*/[imox]*"

    # Escapes
    color red "\\[0-7][0-7][0-7]|\\x[0-9a-fA-F][0-9a-fA-F]"
    color red "\\[abefnrs]"
    color red "(\\c|\\C-|\\M-|\\M-\\C-)."

    # Expression substitution
    color red "#{[^}]*}|#(||\$)\w+"

    # Simple comments
    color cyan "#([^{].*)?$"

    # Shebang
    color brightcyan "^#!.*"

    # Multiline comments
    color cyan start="^=begin" end="^=end"

    ################################################## ###################
    # For this to be functional Nano must be compiled to read
    # $HOME/.nanorc and support syntax highlighting.
    ################################################## ###################

    Josef 'Jupp' SCHUGT
    --
    http://oss.erdfunkstelle.de/ruby/ - German comp.lang.ruby FAQ
    http://rubyforge.org/users/jupp/ - Ruby projects at Rubyforge


    Josef Guest

  2. #2

    Default Ruby Syntax highlighting for *NANO* (Was: Ruby syntax highlighting for Ruby)

    Hi!

    Oops :->
    Well, a Ruby syntax highlighter in Ruby would be interesting, too.

    Josef 'Jupp' Schugt
    --
    http://oss.erdfunkstelle.de/ruby/ - German comp.lang.ruby FAQ
    http://rubyforge.org/users/jupp/ - Ruby projects at Rubyforge


    Josef Guest

  3. #3

    Default Re: Ruby syntax highlighting for Ruby

    Great! Thanks.

    I am getting the following errors, though:


    Error in /root/.nanorc on line 16: Bad regex
    "<=>|\|\||!=|=~|!~|&&|+=|-=|=|\.\.|\.\.\.": Invalid preceding regular
    expression
    Press return to continue starting nano


    Error in /root/.nanorc on line 59: Bad regex "#{[^}]*}|#(||\$)\w+":
    Invalid content of \{\}
    Press return to continue starting nano



    My nano -V gives:

    GNU nano version 1.2.2 (compiled 11:27:12, Oct 11 2003)
    Email: org Web: http://www.nano-editor.org/
    Compiled
    options: --disable-justify --enable-color --enable-multibuffer --enable-nano
    rc



    Chris Guest

  4. #4

    Default Re: Ruby syntax highlighting for Ruby

    Hi!

    * Chris Pine:
    [Errors while nano ps syntax highlighting for Ruby]
     

    Try nano 1.2.3 and report if the problem persists.

    Josef 'Jupp' SCHUGT
    --
    E-Mail: .--- ..- .--. .--. .--.-. --. -- -..- .-.-.- -.. .
    http://oss.erdfunkstelle.de/ruby/ - German comp.lang.ruby FAQ
    http://rubyforge.org/users/jupp/ - Ruby projects at Rubyforge


    Josef Guest

  5. #5

    Default Re: Ruby syntax highlighting for Ruby

    "Josef 'Jupp' SCHUGT" <de> wrote in message news:<20040222183456.GB2853jupp%gmx.de>... 
    >
    > Try nano 1.2.3 and report if the problem persists.
    >
    > Josef 'Jupp' SCHUGT[/ref]

    There were some missing escape backslashes, here are the regexps that work for
    me (nano 1.2.3)

    # Operators
    color brightyellow "::|\*\*|!|~|\*|/|%|\+|-|&|<<|>>|\|\^|>|>=|<|<="
    color brightyellow "<=>|\|\||!=|=~|!~|&&|\+=|-=|=|\.\.|\.\.\."
    color brightyellow "\<not\>|\<and\>|\<or\>"

    # Expression substitution
    color red "#\{[^}]*\}|#(||\$)\w+"
    denis Guest

  6. #6

    Default Re: Ruby syntax highlighting for Ruby

    Hi!

    * denis: 
    >
    > There were some missing escape backslashes, here are the regexps that work for
    > me (nano 1.2.3)
    > color brightyellow "<=>|\|\||!=|=~|!~|&&|\+=|-=|=|\.\.|\.\.\."[/ref]

    The difference is that '+=' has been changed to '\+='. Very strange.
    My nano should have complained about that - but it didn't :-<
     

    Here '#{[^}]*}' has been replaced by '#\{[^}]*\}': Again no error
    message here 8-|

    Josef 'Jupp' Schugt
    --
    E-Mail: .--- ..- .--. .--. .--.-. --. -- -..- .-.-.- -.. .
    http://oss.erdfunkstelle.de/ruby/ - German comp.lang.ruby FAQ
    http://rubyforge.org/users/jupp/ - Ruby projects at Rubyforge


    Josef Guest

Similar Threads

  1. Ruby/Ruby on Rails Syntax Highlight/Code completion
    By Cannikinn in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 1
    Last Post: September 22nd, 01:05 AM
  2. Replies: 3
    Last Post: December 15th, 09:22 AM
  3. Replies: 1
    Last Post: October 29th, 07:52 PM
  4. [ANN] ruby-freedb, ruby-serialport, ruby-mp3info moved to Rubyforge
    By guillaume.pierronnet@ratp.fr in forum Ruby
    Replies: 0
    Last Post: August 31st, 11:57 PM
  5. Ruby syntax-coloring in XEmacs
    By Larry Elmore in forum Ruby
    Replies: 0
    Last Post: July 21st, 01:50 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139