Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move common rules to common module for TypeScript lexer #1530

Merged
merged 1 commit into from
Jun 2, 2020
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
11 changes: 0 additions & 11 deletions lib/rouge/lexers/typescript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ class Typescript < Javascript
filenames '*.ts', '*.d.ts'

mimetypes 'text/typescript'

prepend :root do
rule %r/[?][.]/, Punctuation
end

prepend :statement do
rule %r/(#{Javascript.id_regex})(\??)(\s*)(:)/ do
groups Name::Label, Punctuation, Text, Punctuation
push :expr_start
end
end
end
end
end
13 changes: 13 additions & 0 deletions lib/rouge/lexers/typescript/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ def builtins
Pick Partial Readonly Record
)
end

def self.extended(base)
base.prepend :root do
rule %r/[?][.]/, base::Punctuation
end

base.prepend :statement do
rule %r/(#{Javascript.id_regex})(\??)(\s*)(:)/ do
groups base::Name::Label, base::Punctuation, base::Text, base::Punctuation
push :expr_start
end
end
end
end
end
end