Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

LTSV scanner#127

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
a2ikm wants to merge1 commit intorubychan:master
base:master
Choose a base branch
Loading
froma2ikm:ltsv
Open
Show file tree
Hide file tree
Changes fromall 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
1 change: 1 addition & 0 deletionslib/coderay/helpers/file_type.rb
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,6 +96,7 @@ def shebang filename
'java' => :java,
'js' => :java_script,
'json' => :json,
'ltsv' => :ltsv,
'mab' => :ruby,
'pas' => :delphi,
'patch' => :diff,
Expand Down
49 changes: 49 additions & 0 deletionslib/coderay/scanners/ltsv.rb
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
module CodeRay
module Scanners

# A scanner for LTSV.
# http://ltsv.org
class Ltsv < Scanner

register_for :ltsv
file_extension 'ltsv'

protected

def scan_tokens encoder, options

state = :initial

until eos?

if match = scan(/(?:\r?\n)+/)
encoder.text_token match, :space
state = :initial if match.index(/\r?\n/)

elsif (state == :initial || state == :tab) && match = scan(/[^:]+/)
encoder.text_token match, :key
state = :label

elsif state == :label && match = scan(/:/)
encoder.text_token match, :delimiter
state = :colon

elsif state == :colon && match = scan(/[^\t\r\n]*/)
encoder.text_token match, :value
state = :value

elsif state == :value && match = scan(/\t/)
encoder.text_token match, :space
state = :tab

else
raise
end
end

encoder
end
end

end
end

[8]ページ先頭

©2009-2025 Movatter.jp