Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add language support for PHP #35

Closed
wants to merge 1 commit into from

2 participants

@bobthecow

It seems like there should be a simpler way to map languages to comment styles. Mebbe a shortcut definition for 'c-ish comments'?

@bobthecow

Maybe something like this?

C_ISH_COMMENT_STYLE = {
  :single => "//",
  :multi  => { :start => "/**", :middle => "*", :end => "*/" }
}
COMMENT_STYLES  = {
  "bash"          =>  { :single => "#", :multi => nil },
  "c"             =>  C_ISH_COMMENT_STYLE,
  "coffee-script" =>  {
    :single => "#",
    :multi  => { :start => "###", :middle => nil, :end => "###" }
  },
  "cpp"           =>  C_ISH_COMMENT_STYLE,
  "css"           =>  {
    :single => nil,
    :multi  => { :start => "/**", :middle => "*", :end => "*/" }
  },
  "java"          =>  C_ISH_COMMENT_STYLE,
  "js"            =>  C_ISH_COMMENT_STYLE,
  "lua"           =>  {
    :single => "--",
    :multi => nil
  },
  "php"           =>  C_ISH_COMMENT_STYLE,
  "python"        =>  {
    :single => "#",
    :multi  => { :start => '"""', :middle => nil, :end => '"""' }
  },
  "rb"            =>  {
    :single => "#",
    :multi  => { :start => '=begin', :middle => nil, :end => '=end' }
  },
  "scheme"        =>  { :single => ";;",  :multi => nil },
}
@mikewest mikewest referenced this pull request from a commit
@bobthecow bobthecow Adding PHP syntax.
Closes issue #35.
fe09cbe
@mikewest
Collaborator

I like it. Done.

@mikewest mikewest closed this
@bobthecow

Great. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2011
  1. @bobthecow
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/rocco.rb
View
4 lib/rocco.rb
@@ -238,6 +238,10 @@ def detect_language
:single => "--",
:multi => nil
},
+ "php" => {
+ :single => "//",
+ :multi => { :start => "/**", :middle => "*", :end => "*/" }
+ },
"python" => {
:single => "#",
:multi => { :start => '"""', :middle => nil, :end => '"""' }
Something went wrong with that request. Please try again.