Skip to content

Commit

Permalink
Merge branch 'rouge-ruby:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
griano authored May 14, 2023
2 parents ab728d5 + 96b11b5 commit efcb889
Show file tree
Hide file tree
Showing 20 changed files with 864 additions and 446 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ syntax highlighter relies for its success on submissions from users of the
languages being highlighted. You can help Rouge by filing bug reports or
developing new lexers.

Everyone interacting in Rouge and its sub-projects' code bases is expected to
follow the Rouge [Code of Conduct][code-of-conduct].

[code-of-conduct]: CODE_OF_CONDUCT.md

### Bug Reports

Rouge uses GitHub's Issues to report bugs. You can [choose][issue-chooser] from
Expand Down Expand Up @@ -299,5 +304,7 @@ Jeanine Adkisson, Drew Blessing (@dblessing), Goro Fuji (@gfx) and Tan Le

## License

Rouge is released under the MIT license. Please see the `LICENSE` file for more
Rouge is released under the MIT license. Please see the [LICENSE][license] file for more
information.

[license]: LICENSE
7 changes: 7 additions & 0 deletions lib/rouge/guessers/disambiguation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def match?(filename)

disambiguate '*.cls' do
next TeX if matches?(/\A\s*(?:\\|%)/)
next OpenEdge if matches?(/(no\-undo|BLOCK\-LEVEL|ROUTINE\-LEVEL|&ANALYZE\-SUSPEND)/i)
next Apex
end

Expand All @@ -139,6 +140,12 @@ def match?(filename)

Puppet
end

disambiguate '*.p' do
next Prolog if contains?(':-')
next Prolog if matches?(/\A\w+(\(\w+\,\s*\w+\))*\./)
next OpenEdge
end
end
end
end
12 changes: 6 additions & 6 deletions lib/rouge/lexers/dart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ class Dart < RegexLexer
mimetypes 'text/x-dart'

keywords = %w(
as assert await break case catch continue default do else finally for
if in is new rethrow return super switch this throw try while with yield
as assert await break case catch continue default do else finally for if
in is new rethrow return super switch this throw try while when with yield
)

declarations = %w(
abstract async dynamic const covariant external extends factory final get
implements late native on operator required set static sync typedef var
abstract base async dynamic const covariant external extends factory final get implements
inline interface late native on operator required sealed set static sync typedef var
)

types = %w(bool Comparable double Dynamic enum Function int List Map Never Null num Object Pattern Set String Symbol Type Uri void)
types = %w(bool Comparable double Dynamic enum Function int List Map Never Null num Object Pattern Record Set String Symbol Type Uri void)

imports = %w(import deferred export library part\s*of part source)

Expand Down Expand Up @@ -53,7 +53,7 @@ class Dart < RegexLexer
rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration
rule %r/(?:#{types.join('|')})\b/, Keyword::Type
rule %r/(?:true|false|null)\b/, Keyword::Constant
rule %r/(?:class|interface|mixin)\b/, Keyword::Declaration, :class
rule %r/(?:class|mixin)\b/, Keyword::Declaration, :class
rule %r/(?:#{imports.join('|')})\b/, Keyword::Namespace, :import
rule %r/(\.)(#{id})/ do
groups Operator, Name::Attribute
Expand Down
9 changes: 8 additions & 1 deletion lib/rouge/lexers/javascript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,14 @@ def self.id_regex

rule %r/function(?=(\(.*\)))/, Keyword::Declaration # For anonymous functions

rule %r/(#{id})[ \t]*(?=(\(.*\)))/m, Name::Function
rule %r/(#{id})[ \t]*(?=(\(.*\)))/m do |m|
if self.class.keywords.include? m[1]
# "if" in "if (...)" or "switch" in "switch (...)" are recognized as keywords.
token Keyword
else
token Name::Function
end
end

rule %r/[{}]/, Punctuation, :statement

Expand Down
20 changes: 10 additions & 10 deletions lib/rouge/lexers/jinja.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ class Jinja < TemplateLexer
'text/html+django', 'text/html+jinja'

def self.keywords
@@keywords ||= %w(as context do else extends from ignore missing
import include reversed recursive scoped
autoescape endautoescape block endblock call endcall
filter endfilter for endfor if endif macro endmacro
set endset trans endtrans with endwith without)
@keywords ||= %w(as context do else extends from ignore missing
import include reversed recursive scoped
autoescape endautoescape block endblock call endcall
filter endfilter for endfor if endif macro endmacro
set endset trans endtrans with endwith without)
end

def self.tests
@@tests ||= %w(callable defined divisibleby equalto escaped even iterable
lower mapping none number odd sameas sequence string
undefined upper)
@tests ||= %w(callable defined divisibleby equalto escaped even iterable
lower mapping none number odd sameas sequence string
undefined upper)
end

def self.pseudo_keywords
@@pseudo_keywords ||= %w(true false none True False None)
@pseudo_keywords ||= %w(true false none True False None)
end

def self.word_operators
@@word_operators ||= %w(is in and or not)
@word_operators ||= %w(is in and or not)
end

state :root do
Expand Down
4 changes: 0 additions & 4 deletions lib/rouge/lexers/mosel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class Mosel < RegexLexer

mimetypes 'text/x-mosel'

def self.detect?(text)
return true if text =~ /^\s*(model|package)\s+/
end

id = /[a-zA-Z_][a-zA-Z0-9_]*/

############################################################################################################################
Expand Down
Loading

0 comments on commit efcb889

Please sign in to comment.