diff options
author | murphy <murphy@rubychan.de> | 2008-01-07 14:17:43 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2008-01-07 14:17:43 +0000 |
commit | bbbbc70a0b2efcd03bbcaf4e08ac139e7969e608 (patch) | |
tree | 8eb543ee3633ebedd3746b5557c77df0e8612a2a /etc/todo/latex.rb | |
parent | a08d41bb16104ad52ecf612c81f75f531af87d25 (diff) | |
download | coderay-bbbbc70a0b2efcd03bbcaf4e08ac139e7969e608.tar.gz |
Added etc/todo (scanner drafts) and two TextMate project files.
Diffstat (limited to 'etc/todo/latex.rb')
-rw-r--r-- | etc/todo/latex.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/etc/todo/latex.rb b/etc/todo/latex.rb new file mode 100644 index 0000000..5a6e309 --- /dev/null +++ b/etc/todo/latex.rb @@ -0,0 +1,44 @@ +module CodeRay +module Encoders + + class Latex < Encoder + + include Streamable + register_for :latex + + FILE_EXTENSION = 'tex' + + ALLTT_ESCAPE = { #:nodoc: + '{' => '\lb', + '}' => '\rb', + '\\' => '\bs', + } + + HTML_ESCAPE_PATTERN = /[\\{}]/ + + protected + + def text_token text, kind + if text =~ /#{HTML_ESCAPE_PATTERN}/o + text = text.gsub(/#{HTML_ESCAPE_PATTERN}/o) { |m| @HTML_ESCAPE[m] } + end + k = Tokens::ClassOfKind[kind] + if k == :NO_HIGHLIGHT + text + else + "\\CR#{k}{#{text}}" + end + end + + def open_token kind + "\\CR#{Tokens::ClassOfKind[kind]}{" + end + + def close_token kind + "}" + end + + end + +end +end |