diff options
author | murphy <murphy@rubychan.de> | 2008-09-12 00:34:51 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2008-09-12 00:34:51 +0000 |
commit | 4b542fa158a71cbe0b75ffb9b3a777a1b564f6d7 (patch) | |
tree | 403d7b8d2387c66afa5e0d0c5b7da6407904d5ba /etc/todo/latex.murphy.rb | |
parent | dbc30e76d948abfe3cb2fe5a5a001cd065344d6b (diff) | |
download | coderay-4b542fa158a71cbe0b75ffb9b3a777a1b564f6d7.tar.gz |
More cleanup of todo folder.
Diffstat (limited to 'etc/todo/latex.murphy.rb')
-rw-r--r-- | etc/todo/latex.murphy.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/etc/todo/latex.murphy.rb b/etc/todo/latex.murphy.rb new file mode 100644 index 0000000..5a6e309 --- /dev/null +++ b/etc/todo/latex.murphy.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 |