From f4f9ad8b229d19cdcfe15353b45a29a9f1ea5a3e Mon Sep 17 00:00:00 2001 From: Jonathan Wilkins Date: Thu, 5 Jul 2012 17:37:27 -0700 Subject: [PATCH] added comments to extract comment tokens --- lib/coderay/encoders/comments.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/coderay/encoders/comments.rb diff --git a/lib/coderay/encoders/comments.rb b/lib/coderay/encoders/comments.rb new file mode 100644 index 00000000..e6d1e8e7 --- /dev/null +++ b/lib/coderay/encoders/comments.rb @@ -0,0 +1,23 @@ +require 'ruby-debug' +module CodeRay +module Encoders + + load :token_kind_filter + + # A simple Filter that filters tokens except :comment kind. + # + # Usage: + # CodeRay.scan('print # foo', :ruby).comments.text + # #-> "foo" + # + # See also: TokenKindFilter, LinesOfCode + class CodeFilter < TokenKindFilter + + register_for :comments + + DEFAULT_OPTIONS = superclass::DEFAULT_OPTIONS.merge \ + :include => [:comment, :doctype, :docstring, :end_line] + + end +end +end