Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ Style:
Layout:
Enabled: false

Layout/TrailingWhitespace:
Enabled: true
AllowInHeredoc: true

Layout/IndentationStyle:
Enabled: true
IndentationWidth: 2
EnforcedStyle: spaces

Layout/IndentationWidth:
Enabled: true

Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: variable

Layout/EndOfLine:
Enabled: true

Layout/TrailingEmptyLines:
Enabled: true

Metrics:
Enabled: false

Expand Down
4 changes: 2 additions & 2 deletions lib/rouge/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def run
formatter.format(lexer.lex(input)) { |piece| print piece }
end

private_class_method def self.parse_cgi(str)
private_class_method def self.parse_cgi(str)
pairs = URI.decode_www_form(str).map { |k, v| [k.to_sym, v] }
Hash[pairs]
end
Expand Down Expand Up @@ -510,7 +510,7 @@ def run
end


private_class_method def self.normalize_syntax(argv)
private_class_method def self.normalize_syntax(argv)
out = []
argv.each do |arg|
case arg
Expand Down
4 changes: 2 additions & 2 deletions lib/rouge/lexers/bicep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Bicep < Rouge::RegexLexer

def self.keywords
@keywords ||= Set.new %w(
as assert existing extends extension false for from func if import in metadata module
as assert existing extends extension false for from func if import in metadata module
none null output param provider resource targetScope test true type using var void with
)
end
Expand Down Expand Up @@ -76,7 +76,7 @@ def self.functions
# Ignore whitespace
rule %r/\s+/, Text
end

state :comments do
rule %r(//[^\n\r]+), Comment::Single
rule %r(/\*.*?\*/)m, Comment::Multiline
Expand Down
4 changes: 2 additions & 2 deletions lib/rouge/lexers/cuda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def self.keywords_type
short1 short2 short3 short4 ushort1 ushort2 ushort3 ushort4
int1 int2 int3 int4 uint1 uint2 uint3 uint4
long1 long2 long3 long4 ulong1 ulong2 ulong3 ulong4
longlong1 longlong2 longlong3 longlong4
ulonglong1 ulonglong2 ulonglong3 ulonglong4
longlong1 longlong2 longlong3 longlong4
ulonglong1 ulonglong2 ulonglong3 ulonglong4
float1 float2 float3 float4 double1 double2 double3 double4
dim3
))
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/lexers/dafny.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Dafny < RegexLexer
schar = /(?:[^\\"\n\r]|\\["'ntr\\0])/
uchar = /(?:\\u#{hex_digit}{4})/

## IMPORTANT: Rules are ordered, which allows later rules to be
## IMPORTANT: Rules are ordered, which allows later rules to be
## simpler than they would otherwise be
state :root do
rule %r(/\*), Comment::Multiline, :comment
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/lexers/datastudio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def self.sql_keywords
rule %r/#{id}(?=\s*[(])/, Name::Function
rule id do |m|
name = m[0].upcase

if self.class.sql_keywords.include? name
token Keyword
else
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/lexers/glsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def self.keywords
def self.keywords_type
@keywords_type ||= Set.new %w(
int void bool float double

vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4
uint uvec2 uvec3 uvec4
dvec2 dvec3 dvec4
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/lexers/go.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class Go < RegexLexer
| rune | string | uint8
| uint16 | uint32 | uint64
| uintptr | uint
)\b/x
)\b/x

PREDECLARED_CONSTANTS = /\b(?:true|false|iota|nil)\b/

Expand Down
4 changes: 2 additions & 2 deletions lib/rouge/lexers/haxe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def self.builtins
state :root do
rule %r/\n/, Text, :statement
rule %r(\{), Punctuation, :expr_start

mixin :comments_and_whitespace

rule %r/@/, Name::Decorator, :metadata
Expand Down Expand Up @@ -254,7 +254,7 @@ def self.builtins
rule %r/\\x\h{2}/, Str::Escape
rule %r/\\u\h{4}/, Str::Escape
rule %r/\\u\{\h{1,6}\}/, Str::Escape
end
end

state :str_interpol do
rule %r/\}/, Str::Interpol, :pop!
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/lexers/idris.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def self.prelude_functions

rule %r/\[\s*\]/, Keyword::Type
rule %r/\(\s*\)/, Name::Builtin

# Quasiquotations
rule %r/(\[)([_a-z][\w']*)(\|)/ do |m|
token Operator, m[1]
Expand Down
238 changes: 119 additions & 119 deletions lib/rouge/lexers/jsp.rb
Original file line number Diff line number Diff line change
@@ -1,119 +1,119 @@
# -*- coding: utf-8 -*- #
# frozen_string_literal: true
module Rouge
module Lexers
class JSP < TemplateLexer
desc 'JSP'
tag 'jsp'
filenames '*.jsp'
mimetypes 'text/x-jsp', 'application/x-jsp'
def initialize(*)
super
@java = Java.new
end
directives = %w(page include taglib)
actions = %w(scriptlet declaration expression)
state :root do
rule %r/<%--/, Comment, :jsp_comment
rule %r/<%@\s*(#{directives.join('|')})\s*/, Name::Tag, :jsp_directive
rule %r/<jsp:directive\.(#{directives.join('|')})/, Name::Tag, :jsp_directive2
rule %r/<jsp:(#{actions.join('|')})>/, Name::Tag, :jsp_expression
# start of tag, e.g. <c:if>
rule %r/<[a-zA-Z]*:[a-zA-Z]*\s*/, Name::Tag, :jsp_tag
# end of tag, e.g. </c:if>
rule %r(</[a-zA-Z]*:[a-zA-Z]*>), Name::Tag
rule %r/<%[!=]?/, Name::Tag, :jsp_expression2
# fallback to HTML
rule(/(.+?)(?=(<%|<\/?[a-zA-Z]*:))/m) { delegate parent }
rule(/.+/m) { delegate parent }
end
state :jsp_comment do
rule %r/(--%>)/, Comment, :pop!
rule %r/./m, Comment
end
state :jsp_directive do
rule %r/(%>)/, Name::Tag, :pop!
mixin :attributes
rule(/(.+?)(?=%>)/m) { delegate parent }
end
state :jsp_directive2 do
rule %r!(/>)!, Name::Tag, :pop!
mixin :attributes
rule(/(.+?)(?=\/>)/m) { delegate parent }
end
state :jsp_expression do
rule %r/<\/jsp:(#{actions.join('|')})>/, Name::Tag, :pop!
mixin :attributes
rule(/[^<\/]+/) { delegate @java }
end
state :jsp_expression2 do
rule %r/%>/, Name::Tag, :pop!
rule(/[^%>]+/) { delegate @java }
end
state :jsp_tag do
rule %r/\/?>/, Name::Tag, :pop!
mixin :attributes
rule(/(.+?)(?=\/?>)/m) { delegate parent }
end
state :attributes do
rule %r/\s*[a-zA-Z0-9_:-]+\s*=\s*/m, Name::Attribute, :attr
end
state :attr do
rule %r/"/ do
token Str
goto :double_quotes
end
rule %r/'/ do
token Str
goto :single_quotes
end
rule %r/[^\s>]+/, Str, :pop!
end
state :double_quotes do
rule %r/"/, Str, :pop!
rule %r/\$\{/, Str::Interpol, :jsp_interp
rule %r/[^"]+/, Str
end
state :single_quotes do
rule %r/'/, Str, :pop!
rule %r/\$\{/, Str::Interpol, :jsp_interp
rule %r/[^']+/, Str
end
state :jsp_interp do
rule %r/\}/, Str::Interpol, :pop!
rule %r/'/, Literal, :jsp_interp_literal_start
rule(/[^'\}]+/) { delegate @java }
end
state :jsp_interp_literal_start do
rule %r/'/, Literal, :pop!
rule %r/[^']+/, Literal
end
end
end
end
# -*- coding: utf-8 -*- #
# frozen_string_literal: true

module Rouge
module Lexers
class JSP < TemplateLexer
desc 'JSP'
tag 'jsp'
filenames '*.jsp'
mimetypes 'text/x-jsp', 'application/x-jsp'

def initialize(*)
super
@java = Java.new
end

directives = %w(page include taglib)
actions = %w(scriptlet declaration expression)

state :root do

rule %r/<%--/, Comment, :jsp_comment

rule %r/<%@\s*(#{directives.join('|')})\s*/, Name::Tag, :jsp_directive

rule %r/<jsp:directive\.(#{directives.join('|')})/, Name::Tag, :jsp_directive2

rule %r/<jsp:(#{actions.join('|')})>/, Name::Tag, :jsp_expression

# start of tag, e.g. <c:if>
rule %r/<[a-zA-Z]*:[a-zA-Z]*\s*/, Name::Tag, :jsp_tag

# end of tag, e.g. </c:if>
rule %r(</[a-zA-Z]*:[a-zA-Z]*>), Name::Tag

rule %r/<%[!=]?/, Name::Tag, :jsp_expression2

# fallback to HTML
rule(/(.+?)(?=(<%|<\/?[a-zA-Z]*:))/m) { delegate parent }
rule(/.+/m) { delegate parent }
end

state :jsp_comment do
rule %r/(--%>)/, Comment, :pop!
rule %r/./m, Comment
end

state :jsp_directive do
rule %r/(%>)/, Name::Tag, :pop!
mixin :attributes
rule(/(.+?)(?=%>)/m) { delegate parent }
end

state :jsp_directive2 do
rule %r!(/>)!, Name::Tag, :pop!
mixin :attributes
rule(/(.+?)(?=\/>)/m) { delegate parent }
end

state :jsp_expression do
rule %r/<\/jsp:(#{actions.join('|')})>/, Name::Tag, :pop!
mixin :attributes
rule(/[^<\/]+/) { delegate @java }
end

state :jsp_expression2 do
rule %r/%>/, Name::Tag, :pop!
rule(/[^%>]+/) { delegate @java }
end

state :jsp_tag do
rule %r/\/?>/, Name::Tag, :pop!
mixin :attributes
rule(/(.+?)(?=\/?>)/m) { delegate parent }
end

state :attributes do
rule %r/\s*[a-zA-Z0-9_:-]+\s*=\s*/m, Name::Attribute, :attr
end

state :attr do
rule %r/"/ do
token Str
goto :double_quotes
end

rule %r/'/ do
token Str
goto :single_quotes
end

rule %r/[^\s>]+/, Str, :pop!
end

state :double_quotes do
rule %r/"/, Str, :pop!
rule %r/\$\{/, Str::Interpol, :jsp_interp
rule %r/[^"]+/, Str
end

state :single_quotes do
rule %r/'/, Str, :pop!
rule %r/\$\{/, Str::Interpol, :jsp_interp
rule %r/[^']+/, Str
end

state :jsp_interp do
rule %r/\}/, Str::Interpol, :pop!
rule %r/'/, Literal, :jsp_interp_literal_start
rule(/[^'\}]+/) { delegate @java }
end

state :jsp_interp_literal_start do
rule %r/'/, Literal, :pop!
rule %r/[^']+/, Literal
end
end
end
end
Loading