Skip to content

Commit

Permalink
Highlight Ruby method definitions without arguments
Browse files Browse the repository at this point in the history
Inheriting from `clike` is enough to deal with constructs like this

```ruby
def foo(bar)
  ...
end
```

but not

```ruby
def foo
  ...
end
```

This does not highlight call sites, but since much idiomatic Ruby
doesn't use parentheses in function calls, call sites can't be
consistently highlighted anyway.
  • Loading branch information
cbothner committed Aug 14, 2018
1 parent 9d15ff6 commit 8173ec6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions components/prism-ruby.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
greedy: true
}
],
'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/
'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/,
'function': {
pattern: /(def )[\w.]+/,
lookbehind: true,
greedy: true
}
});

var interpolation = {
Expand Down Expand Up @@ -128,4 +133,4 @@
}
}
];
}(Prism));
}(Prism));
2 changes: 1 addition & 1 deletion components/prism-ruby.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8173ec6

Please sign in to comment.