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

TaskPaper scanner #39

Merged
merged 1 commit into from Jun 12, 2013
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions lib/coderay/scanners/taskpaper.rb
@@ -0,0 +1,34 @@
module CodeRay
module Scanners

class Taskpaper < Scanner

register_for :taskpaper
file_extension 'taskpaper'

protected

def scan_tokens encoder, options
until eos?
if match = scan(/^\S.*:.*$/) # project
encoder.text_token(match, :project)
elsif match = scan(/^-.+@done(?:\(.*)?.*$/) # completed task
encoder.text_token(match, :complete)
elsif match = scan(/^-.+$/) # task
encoder.text_token(match, :plain)
elsif match = scan(/^.+$/) # comment
encoder.text_token(match, :comment)
elsif match = scan(/\s+/) # space
encoder.text_token(match, :space)
else # other
encoder.text_token getch, :error
end
end

encoder
end

end

end
end
3 changes: 3 additions & 0 deletions lib/coderay/styles/alpha.rb
Expand Up @@ -134,6 +134,9 @@ class Alpha < Style
.delete .delete { color: #c00; background:transparent; font-weight:bold }
.change .change { color: #88f }
.head .head { color: #f4f }

.project { color: #707; font-weight: bold }
.complete { text-decoration: line-through; color: gray }
TOKENS

end
Expand Down
3 changes: 3 additions & 0 deletions lib/coderay/token_kinds.rb
Expand Up @@ -74,6 +74,9 @@ module CodeRay
:insert => 'insert',

:eyecatcher => 'eyecatcher',

:project => 'project',
:complete => 'complete',

:ident => false,
:operator => false,
Expand Down