Skip to content

Commit aeac667

Browse files
committed
TaskPaper scanner for CodeRay
1 parent 3effca8 commit aeac667

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

lib/coderay/scanners/taskpaper.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module CodeRay
2+
module Scanners
3+
4+
class Taskpaper < Scanner
5+
6+
register_for :taskpaper
7+
file_extension 'taskpaper'
8+
9+
protected
10+
11+
def scan_tokens encoder, options
12+
until eos?
13+
if match = scan(/^\S.*:.*$/) # project
14+
encoder.text_token(match, :project)
15+
elsif match = scan(/^-.+@done(?:\(.*)?.*$/) # completed task
16+
encoder.text_token(match, :complete)
17+
elsif match = scan(/^-.+$/) # task
18+
encoder.text_token(match, :plain)
19+
elsif match = scan(/^.+$/) # comment
20+
encoder.text_token(match, :comment)
21+
elsif match = scan(/\s+/) # space
22+
encoder.text_token(match, :space)
23+
else # other
24+
encoder.text_token getch, :error
25+
end
26+
end
27+
28+
encoder
29+
end
30+
31+
end
32+
33+
end
34+
end

lib/coderay/styles/alpha.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ class Alpha < Style
134134
.delete .delete { color: #c00; background:transparent; font-weight:bold }
135135
.change .change { color: #88f }
136136
.head .head { color: #f4f }
137+
138+
.project { color: #707; font-weight: bold }
139+
.complete { text-decoration: line-through; color: gray }
137140
TOKENS
138141

139142
end

lib/coderay/token_kinds.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ module CodeRay
7474
:insert => 'insert',
7575

7676
:eyecatcher => 'eyecatcher',
77+
78+
:project => 'project',
79+
:complete => 'complete',
7780

7881
:ident => false,
7982
:operator => false,

0 commit comments

Comments
 (0)