Skip to content

Commit abdc3e4

Browse files
committed
tweak Taskpaper scanner, cleanup doc_string kind
1 parent ce3f838 commit abdc3e4

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

lib/coderay/encoders/terminal.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Terminal < Encoder
3737
:directive => "\e[32m\e[4m",
3838
:doc => "\e[46m",
3939
:doctype => "\e[1;30m",
40-
:doc_string => "\e[31m\e[4m",
40+
:docstring => "\e[31m\e[4m",
4141
:entity => "\e[33m",
4242
:error => "\e[1;33m\e[41m",
4343
:exception => "\e[1;31m",

lib/coderay/scanners/taskpaper.rb

+10-8
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ class Taskpaper < Scanner
1010

1111
def scan_tokens encoder, options
1212
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
13+
if match = scan(/\S.*:.*$/) # project
14+
encoder.text_token(match, :namespace)
15+
elsif match = scan(/-.+@done.*/) # completed task
16+
encoder.text_token(match, :done)
17+
elsif match = scan(/-(?:[^@\n]+|@(?!due))*/) # task
1818
encoder.text_token(match, :plain)
19-
elsif match = scan(/^.+$/) # comment
19+
elsif match = scan(/@due.*/) # comment
20+
encoder.text_token(match, :important)
21+
elsif match = scan(/.+/) # comment
2022
encoder.text_token(match, :comment)
21-
elsif match = scan(/\s+/) # space
23+
elsif match = scan(/\s+/) # space
2224
encoder.text_token(match, :space)
23-
else # other
25+
else # other
2426
encoder.text_token getch, :error
2527
end
2628
end

lib/coderay/styles/alpha.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ class Alpha < Style
141141
.change .change { color: #88f }
142142
.head .head { color: #f4f }
143143
144-
.project { color: #707; font-weight: bold }
145-
.complete { text-decoration: line-through; color: gray }
144+
.done { text-decoration: line-through; color: gray }
146145
TOKENS
147146

148147
end

lib/coderay/token_kinds.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ module CodeRay
2929
:directive => 'directive',
3030
:doc => 'doc',
3131
:doctype => 'doctype',
32-
:doc_string => 'doc-string',
32+
:docstring => 'doc-string',
33+
:done => 'done',
3334
:entity => 'entity',
3435
:error => 'error',
3536
:escape => 'escape',
@@ -75,9 +76,6 @@ module CodeRay
7576
:insert => 'insert',
7677

7778
:eyecatcher => 'eyecatcher',
78-
79-
:project => 'project',
80-
:complete => 'complete',
8179

8280
:ident => false,
8381
:operator => false,
@@ -87,6 +85,4 @@ module CodeRay
8785
)
8886

8987
TokenKinds[:method] = TokenKinds[:function]
90-
TokenKinds[:escape] = TokenKinds[:delimiter]
91-
TokenKinds[:docstring] = TokenKinds[:comment]
9288
end

0 commit comments

Comments
 (0)